


Adds the Aperture Science Handheld Portal Device to the list of shop items. Press E to toggle portal gun mode while holding the item, and then it controls like the portal gun controls in its games. Semibots, enemies, loot, and everything else should pass through fine.
Still in testing. Portals touch a lot of game systems, so expect some jank. Everyone in the lobby needs the mod installed. Portal placement is synced, and there is one gun per run.
PortalQuality setting lowers the resolution of that view to save performance. Its default, Auto, does that on its own when your framerate drops.Auto: Auto drops the resolution under load, High renders it at full resolution, Balanced at half, Performance at a third.false: developer test keys, off for normal play.Requires REPOLib for item registration and the networking below. The rendering math, relative-transform camera mirroring with an oblique near-clip projection, is ported from Sebastian Lague's MIT-licensed Portals project, and the portal screen shader is his Custom/Portal shader shipped as-is in the asset bundle.
Teleport core. Crossing detection is an analytic FixedUpdate check with no Unity trigger callbacks or collision-matrix involvement. The trigger volume extrudes 0.4m out from the portal face, 1.4m for items whose centers sit farther from walls. A body-center plane check alone can never fire on a wall-mounted portal, because the wall's own collider stops the player capsule about 0.3 to 0.4m short of a quad 0.05m off the surface. Exit placement is inset 0.8m from the destination wall, outside that portal's own trigger volume so arriving cannot re-trigger, with a minimum exit speed of 1 m/s and a 1s per-object cooldown against ping-pong. Velocity carries through the portal-pair rotation delta, and camera rotation applies through CameraAim.SetPlayerAim, since raw Transform writes lose to CameraAim's per-frame recompute. One measured value matters when forking this: REPO's player rigidbody falls at about 2.5x Physics.gravity, so vertical-launch math has to use the measured figure.
Rendering. The portal camera's far plane is computed per render, the player-to-portal distance plus the main camera's fog-tight view distance of about 23m, clamped to 30 to 150. PortalQuality maps to a render-texture downscale of 1 for High, 2 for Balanced, 3 for Performance, and Auto also skips portal-camera renders under sustained frame-time load.
Enemy awareness. Sound events near one portal are remapped through EnemyDirector.SetInvestigate to the paired opening, and throttled master-only EnemyVision.VisionTrigger relays let an enemy that sees one portal react to a player at the other. Enemies cannot path through. They cross only when their physics body crosses the plane.
Multiplayer. Portal fire and clear are REPOLib NetworkedEvents, "PortalGunFire" and "PortalGunClear", reliable and raised to others, and each client places the same quad locally. Item and player crossings resolve on the owner's side. RunManager.ChangeLevel runs only on the master, so per-level cleanup accounts for non-master clients separately.
Shop wiring. The item registers through REPOLib's bundle scan, then a fixup pass prices it at $15k to $20k over the bundle's placeholder, sets itemType to a shop-eligible tool type, sets itemVolume = medium so shop shelves place it at a medium slot, and sets maxAmountInShop = 1. A singleton guard keeps it one per run against a dupe glitch or another mod spawning a second.
A portal needs a flat area big enough for the quad. Too curved, too small, or too close to an edge and it fizzles instead of placing. Re-firing a portal moves it.