How to direct a part in the direction of its speed

I am making a rocket that flies along a ballistic trajectory, which is calculated due to physics. The problem is that my rocket is always turned up when flying and does not look in the direction of movement. I tried to use alignorientation, but I didn’t find how to bind alignorientation to the speed of the part. Ideas?

1 Like

Can you show your code?

1 Like

can you tell me how to lay out the code so that it is in a convenient format? I’m just recently on the forum

1 Like

You can make the AlignOrientation align the rocket to CFrame.lookAt(Vector3.zero, Rocket.AssemblyLinearVelocity). Alternatively just set the CFrame incase you don’t want to use physics to rotate it.

1 Like

my rocket just gone when i run the script xD

1 Like

There is a little icon that displays </>
Click that icon and paste your code inside the tildas.

1 Like

If you want to rotate it using CFrame instead of AlignOrientation, you need to take it’s position into account as well. Try running it like this, if that is the case: CFrame.lookAt(Rocket.Position, Rocket.Position + Rocket.AssemblyLinearVelocity)

1 Like

I already fixed it by use this code:

while true do
    task.wait()
    rocket.CFrame = CFrame.lookAt(rocket.Position, rocket.AssemblyLinearVelocity * 100)
end

So there’s only one thing I don’t know. Why is it that if I don’t multiply the rocket.AssemblyLinearVelocity by some number, then my rocket spins and if I divide the rocket.AssemblyLinearVelocity by 5, for example, then it will spin even more

1 Like
local pos = rocket.Position
game:GetService("RunService").Stepped:Connect(function()
    rocket.CFrame = CFrame.new(pos, rocket.Position)
    pos = rocket.Position
end)
1 Like

Who knows how this works, XD ?

1 Like