I have been away from Roblox for a bit and I decided to give a try to Unity and other Game Engines.
I’m back on Roblox and I’m a bit confused about one point.
I’m working on a game in which I have to rotate a lot of elements towards a unit direction.
On Unity, we had a simple way of doing that with the Quaternion.LookRotation(dir, axisVector).
For example, I’d like an arrow to rotate towards a cube only in the up axis.
This seems fairly easy to do but I can’t find any answers with these words so I thought it could help me and maybe a lot of other developers since this is a pretty much useful feature.
Hope you’ll be able to help me,
Thanks in advance !
one thing i’ve used to lock a rotation of something is this
local newCFrame = CFrame.new(Character.HumanoidRootPart.Position, mouseForChar.Hit.Position)
local x, y, z = newCFrame:ToOrientation()
Character.HumanoidRootPart.CFrame = CFrame.new(Character.HumanoidRootPart.Position) * CFrame.fromOrientation(0, y, z)
This is for locking the character to the mouse but locking the x axis
you could modify it to look like this
local newCFrame = CFrame.new(arrow.Position, cube.Position)
local x, y, z = newCFrame:ToOrientation()
arrow.CFrame = CFrame.new(arrow.Position) * CFrame.fromOrientation(0, y, 0)