Portal Gun

Description:
A fully functional Portal Gun. This is by far the most eloquent and bug-free portal gun available within Garry’s Mod.
Left click to shoot a blue portal. Right click to shoot an orange portal. Reload to remove all portals. Press E to pick up an item.
TO MAKE THE PORTALS WORK RIGHT, RUN “r_novis 1” IN CONSOLE.

Features:
• Portals which look exactly like the portals in Portal 1, with seamless rendering
• Walk through portals just like the game. No more sucking or poofing!
• Standalone, does not require Portal or Portal 2 to work correctly.
• Velocity is (almost) entirely preserved as you enter the portal.
• Optional dynamic lights
• Shoot through portals
• Take props through portals
• Several convars to adjust the portal gun to your liking (listed below).

ConVars:
• portal_arm <0|1> Whether to show the arm in the viewmodel. Requires Portal 2. (default 0)
• portal_beta_borders <0|1> Whether to use different textures for the portals. (default 0)
• portal_borders <0|1> Whether to render portal borders at all (default 1; 0 somewhat improves performance)
• portal_crosshair <0|1> Whether to use the portal crosshair (default 1)
• portal_dynamic_light <0|1> Whether to use dynamic lights with the portals (default 0; 0 drastically improves performance)
• portal_limitcarry <0|1> Whether to limit the portalgun to pick up portal props only (default 1)
• portal_projectile_speed <number> The speed of the projectile shot by the portal gun (default 3500)
• portal_render <0|1> whether to render the other side of the portal (default 1; 0 drastically improves performance)

Links:
Workshop: http://steamcommunity.com/sharedfiles/filedetails/?id=336509414
Github: https://github.com/Luabee/PortalGun

Known Bugs:
• Can’t select the model for tools like button or thruster in sandbox
• Portal projectiles don’t exist in multiplayer
• Multiplayer in general is very unreliable
• Props sometimes fall through the floor when they move through the portal
• Roof portals don’t preserve velocity for players.

Thanks to everyone who helped make this possible, including but not limited to:
**Bobblehead **- Making it actually work and look nice.
**Blackops **- Much Code and models.
**Mahalis **- Some code
**Fernando5567 **- Much code
**Matsilagi **- Models/effects/testing
**Dr. Awesome **- Swirly beta portal materials

I thought mahalis left gmod?

[editline]4th November 2014[/editline]

Very cool either way.

With portal render at 0, is there any performance decrease/lag when you have both portals open? Just wondering if it causes a slight fps drop. Just wondering how much lag there is (if there is any, I recall portal guns being extremely laggy, but that was years ago on an old PC)

Mahalis didn’t help directly, but some of his original code lingers, especially regarding the more complex vector math.

portal_render 0, meaning the portals are either solid blue or solid orange, has no discernible frame rate drop. When actually rendering portals to their render targets with portal_render 1, my frame rate drops from 100±5 to 30±5, but my graphics card is par at best.

portal_dynamic_light 1 drops my framerate by an additional 5 or 10.

How’d you get the movement through portals working? That’s something I could never figure out.

[editline]4th November 2014[/editline]

ahh CreateMove and Move

This is pretty cool, although the workshop link in the OP is broken.

Fixed, my bad.

This is fantastic.

-snip-

Why are the models errors for me, its installed in addons.:frowning:

Strange. Try putting the models within the addon into your root garry’s mod folder.

It’s hard to tell from the video, but does the skybox render through the portals? Other portal gun addons would never render the skybox in the portals.

It’s actually quite spotty. Sometimes it does, sometimes it doesn’t. I can explain why, but it’s not something that can really be solved due to the nature of the issue.
Whether it renders or not is based on the portal’s position and your position relative to the OPPOSITE portal in question.

It’s because of how source makes everything invisible and the sky black if you’re outside of the map or inside something, which you can be rendering from due to how the portals work

It looks like a lot of code and models were taken from my old repo so I would appreciate some credit. :slight_smile:

For example…

https://github.com/Luabee/PortalGun/blob/master/PortalGun/Lua/Entities/prop_portal/cl_init.lua

I would also really recommend not using NWVars and using DTVars instead.

Anyway, nice work finishing what I never could.

Oh my. Originally I was unaware that you had worked on the Portal Gun I had downloaded from garrysmod.org as a starting point.
When I found out how much you had contributed, I added your name to the workshop page, but I guess I forgot to put you here.

I’m glad you like it! I’ll add you now.

Wow i haven’t laughed as hard.
your code:



local dlightenabled = CreateClientConVar("portal_dynamic_light", "0", true) --Kinda laggy, default it to off


his code:



local dlightenabled = CreateClientConVar("portal_dynamic_light", "0", true) --Pretty laggy, default it to off


Yeah iirc this portal gun is basically just lots of old code from various people merged and fixed up

Lol I don’t even remember making that change :stuck_out_tongue:
I think I saw his comment and rewrote it because it seemed weird, and what I wrote turned out exactly the same.

Can somebody tell what’s going on and whether it is possible to correct it?
I looked all ConVars, did not help. Not critical, I would like to fix it …

When I run the map in error console

Attemped to precache unknown particle system “portal_1_projectile_ball”!
Attemped to precache unknown particle system “portal_1_projectile_ball”!
Attemped to precache unknown particle system “portal_2_projectile_ball”!
Attemped to precache unknown particle system “portal_2_projectile_ball”!
Attemped to precache unknown particle system “portal_1_projectile_stream”!
Attemped to precache unknown particle system “portal_1_projectile_stream”!
Attemped to precache unknown particle system “portal_2_projectile_stream”!
Attemped to precache unknown particle system “portal_2_projectile_stream”!
Attemped to precache unknown particle system “portal_1_projectile_trail”!
Attemped to precache unknown particle system “portal_1_projectile_trail”!
Attemped to precache unknown particle system “portal_2_projectile_trail”!
Attemped to precache unknown particle system “portal_2_projectile_trail”!
Particles: Missing ‘particles/portal_beta_particles2.pcf’

Sorry my english :slight_smile: