You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
I want to make a portal that when you go into it facing a certain direction, you come out, facing the same direction relative to the new location
What is the issue? Include screenshots / videos if possible!
I have only been able to make it so that it mirrors the player (the player is in first person so to rotate them I turn the camera in a local script) but if the portal number 2 is on a different rotation axis it does not work correctly, I want it so that if I go into a portal on the front wall that is linked to a portal on the side wall, it will work like this, if you are facing forward toward the portal when you go in, when you come out, you will be facing the same way relative to where you now are, but instead, it just reverses the location
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have tried looking for solutions but there is nothing
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
This is the code I use to rotate the camera
game.ReplicatedStorage.Rotate.OnClientInvoke = function(LookPart)
--lookpart is a part always facing forward relative to the portal
workspace.CurrentCamera.CFrame *= CFrame.Angles(math.pi,math.pi,math.pi)
end
Exact problem in video form (sorry for watermark I had to remove the audio track because I forgot to mute)
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.
so that we can better handle the problem, make it so that when portal1 is touched, it prints the orientation of the humanoidrootpart, and when it has reached portal2, it prints the orientation of the character again, and then you tell me that it was printed
Something I would like to know is why each axis in the angle is pi, I think that would be the reason for the problem too, since math.pi does not guess the orientation of “lookpart”
game.ReplicatedStorage.Rotate.OnClientInvoke = function(LookPart)
--lookpart is a part always facing forward relative to the portal
workspace.CurrentCamera.CFrame *= CFrame.Angles(math.pi,math.pi,math.pi)
end```
I see, I think I could try to figure out how to do it, I’ll try to do something similar, and if you haven’t found the solution yet I’ll tell you how to do it.
Hey, I have been finding out and experimenting, I won’t tell you that I already found the solution, but I can tell you that I am reaching a possible solution.
You could use CFrame:ToObjectSpace() what it does is it rotate given cframe relative to the new one, you even don’t need math for this, here is tutorial: CFrame | Documentation - Roblox Creator Hub
I knew that cframe had a function for that, but I didn’t know which one, could you give an example? Because I tried that but I don’t think it was the way it should be.
I have solved it, answer me and I will immediately send you a file with the model of the 2 blocks and the script, you could also use the method that ideal recommended
OH MY GOD, YOU A GENIOUS, sadly I use linux, therefore importing rblx does not work, could you please send me the camera rotation code, but thank you so much
oh ok sure
Btw, there are 2 scripts, one normal and one local, and they need a remoteEvent in the replicatedstorage, and put the local script in the starterplayerscripts
part = script.Parent
part2 = workspace:WaitForChild("portal2")
Event = game.ReplicatedStorage.RemoteEvent
debounce = true
function OrientationRelative(portal1,portal2,Y)
local num1 = portal1.Orientation.Y - portal2.Orientation.Y
local num2 = Y - num1
local result = num2 - 180
print(Y)
print(num1)
print(num2)
print(result)
return result
end
part.Touched:Connect(function(hit)
if debounce then
if hit.Parent:FindFirstChild("Humanoid") then
debounce = false
local rootpart = hit.Parent.HumanoidRootPart
local AxisY = rootpart.Orientation.Y
rootpart.CFrame = part2.CFrame:ToWorldSpace(CFrame.new(0,0,-4))
local orientation = CFrame.fromOrientation(math.rad(0),math.rad(OrientationRelative(part,part2,AxisY)),math.rad(0))
Event:FireClient(game.Players:GetPlayerFromCharacter(hit.Parent),orientation)
--rootpart.CFrame = CFrame.new(rootpart.Position) * CFrame.fromOrientation(math.rad(0),math.rad(OrientationRelative(part,part2,AxisY)),math.rad(0))
wait(2)
debounce = true
end
end
end)