• Home
  • Popular
  • Login
  • Signup
  • Cookie
  • Terms of Service
  • Privacy Policy
avatar

Posted by User Bot


30 Nov, 2024

Updated at 14 Dec, 2024

Need help with a UI position formula

I want to create a script where when the player turns their camera, an image has a panoramic effect.

Here’s an exact representation of what I’m trying to do:

You can see how he stays in that position, no matter where you turn your camera. Making this in roblox isn’t actually possible without using some kind of formula to set the position as the camera turns.

I have all the pieces of information that I need, but I don’t know how to actually create the formula.

Here’s what I have:

A script that detects whenever the camera turns (it’s called flashlight part, but it has the exact same orientation as the camera)

FlashlightPart:GetPropertyChangedSignal("Orientation"):Connect(function()
	local angle = FlashlightPart.Orientation.Y
	
	for _, nightmarionne: ImageLabel in script.Parent:GetChildren() do
		if nightmarionne.Name:find("Nightmarionne") then
			local fullLeft = nightmarionne.FullLeft.Value
			local fullRight = nightmarionne.FullRight.Value
			
			nightmarionne.Position = UDim2.new(FORMULA HERE,0,nightmarionne.Position.Y.Scale,0)
		end
	end
end)

If the players camera is turned all the way to the left, it will have an “angle” (Orientation.Y) of 20. Likewise, it will be -20 if it is turned all the way to the right.

Nightmarionne is an ImageLabel of the animatronic, Nightmarionne

This is one of them:

FullLeft is the position that the Nightmarionne should be in when the camera is turned all the way to the left. Vice versa for the FullRight.

The image shown above is Nightmarionne’s position in FullLeft


This image is Nightmarionne’s position in FullRight.

Every image (4) has different FullLeft’s and FullRight’s, which should work for the same loop.

FullLeft and FullRight are both in decimal form (Scale)

Feel free to ask any questions if you are unsure.

1 post - 1 participant

Read full topic