I need a little help with a portal system

I’m working on a portal and gravity-shifting system inspired by the one in Ultrakill, but it’s missing a few things, such as:

  • When opening a door, it shouldn’t be obvious that the portal is literally a SurfaceGUI (the door shouldnt be behind the portal; I hope that makes sense).

I also want the system to be very polished, and I don’t know much about math, so any help would be greatly appreciated.

Below, I’ll post a video of the system and a testing place

https://streamable.com/8g309w
TestingPlace.rbxl (103.9 KB)

srr about my english btw

Solution

what is the issue here i dont understand

Why don’t you just have the door open outwards (the other way)?

2 Likes

I forgot to mention it in the main message, but in the normal game, the doors open depending on which side you’re on (if you’re facing the door, it opens backwards, and vice versa, I hope you understand what I mean :3) because im doing a fast-pased game and its for gameplay

1 Like

I recently thought of a solution, which would be to render the door on top of the portal using Trove (I know I’m very dumbass, it’s just the first time I’ve wanted someone to help me) :3

Are you asking for tips on how to improve your creation overall? If so I’d recommend you switch your topic to Creations Feedback

1 Like

oh, ye ill change the topic

Summary

i hate characters limit

What if you position the door on the other end of the portal to match with the current door? So as you open the door, the door on the other end also opens.

1 Like

This is as far as I got - I’m not sure why your portals don’t show the doors.
ONLY_EZR_PortalsTest_PairedDoors.rbxl (104.6 KB)

Code for paired doors
local TweenService = game:GetService("TweenService")

local hinge = script.Parent.Doorframe.Hinge
local prompt = script.Parent.Base.ProximityPrompt
local openValue = script.Parent.OpenValue

local pairedDoor = script.Parent.Parent.Parent[`Portal{script.Parent.Parent.Name == "PortalA" and "B" or "A"}`]:FindFirstChild("Door")

local goalOpen = {}
goalOpen.CFrame = hinge.CFrame * CFrame.Angles(0, math.rad(90), 0)

local goalClose = {}
goalClose.CFrame = hinge.CFrame * CFrame.Angles(0, 0, 0)

local tweenInfo = TweenInfo.new(1)
local tweenOpen = TweenService:Create(hinge, tweenInfo, goalOpen)
local tweenClose = TweenService:Create(hinge, tweenInfo, goalClose)

function open()
	tweenOpen:Play()
	prompt.ActionText = "Close"
	if pairedDoor then
		pairedDoor.OpenValue.Value = true
	end
end

function close()
	tweenClose:Play()
	prompt.ActionText = "Open"

	if pairedDoor then
		pairedDoor.OpenValue.Value = false
	end
end

prompt.Triggered:Connect(function()
	if openValue.Value then
		openValue.Value = false
	else
		openValue.Value = true
	end
end)

openValue.Changed:Connect(function()
	if openValue.Value then
		open()
	else
		close()
	end
end)
1 Like

The logic for finding the paired door looks fragile. If the hierarchy or naming convention changes even slightly, FindFirstChild is going to fail silently or error out. Also, you’re relying on OpenValue.Changed to trigger the tween, which is fine, but the pairedDoor reference is being set once at the top of the script and won’t update if the portal structure changes.

1 Like

It’s not meant to be perfect - it’s more of a “proof of concept” type of thing.

This applies to pretty much everything. The original place requires modules using a static path - that could also fail.


Thanks for the feedback, but instead of fixating on a trivial issue, why don’t you try solving the actual issue?

1 Like

The issue is not the naming convention. You are not showing the doors in the portal, so look at the CFrame or the viewport/surfacegui setup for whatever is rendering the visuals. If the doors are missing from the view, the problem is’t in the logic of the hinge, it’s in how the portal is displaying the content.

1 Like

I understand that. I have tried look through the code that initializes the portals and the module that contains the portal logic. However, I still can’t figure out why it does not render the door. I played around by putting a bunch of parts in front of the other portal, however, only about half of them were shown. I believe this issue is related to the door not showing.

1 Like

If only half the parts are showing up, it sounds like a clipping issue. Check the NearPlane or FarPlane of whatever camera is handling the portal view, or check if the parts are being culled by the viewport bounds.

1 Like

Thank you so much to everyone who helped me fix this! I finally found a simple solution: the door is rendered separately on top of the portal to avoid needing to synchronize multiple doors.

I still need to optimize the system a bit since it’s not entirely my own script (because im bad at maths), but it works better this way :3

Thanks for all

External Media

(ignore why the streamable link appears like that)

I’ll also add a optional ObjectValue for syncronize some doors with portal

The SurfaceGUI depth issue you’re hitting is a classic portal problem. Since SurfaceGUI renders on top of the part it’s attached to, the door geometry will always appear behind the portal visually—which breaks the illusion.Your solution of rendering the door separately is solid. Here’s the technical approach:What you’re doing right:- Separating the portal viewport from the physical door mesh prevents z-fighting and layering issues- Keeps synchronization simple since the portal only needs to track camera/viewport data**To polish this further:**1. Viewport rendering: Use a ViewportFrame instead of SurfaceGUI if you aren’t already. It gives you much better control over what renders and at what depth. You can parent door geometry inside the ViewportFrame’s Camera and it’ll render cleanly without the part underneath interfering.2. Camera math: The heavy lifting is making the portal camera track the player’s perspective correctly. You’ll need: - A reference camera position relative to the portal entrance - Mirror that position through the portal plane to get the exit-side camera position - Use CFrame.lookAt() to orient the viewport camera toward the destination3. Performance: ViewportFrames are cheaper than you’d think, but if you have multiple portals, consider: - Only updating the viewport when the player is within ~50 studs - Reducing viewport resolution on lower-end devices (check UserInputService for device type)4. Polish details: - Add subtle vignetting around portal edges (darken corners in a ScreenGui overlay) - Match lighting between portal camera and world—use GetChildren() on Lighting and replicate properties - Small frame delay (1-2 frames) between world camera and portal camera sells the “different space” feelingPost a snippet of your current viewport setup if you want specific math review—the gravity shift logic is where most devs struggle, and that’s worth optimizing properly.

i alredy fixed that btw, but thanks for feedback :3