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?
Can you show your code?
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
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.
my rocket just gone when i run the script xD
There is a little icon that displays </>
Click that icon and paste your code inside the tildas.
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)
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
local pos = rocket.Position
game:GetService("RunService").Stepped:Connect(function()
rocket.CFrame = CFrame.new(pos, rocket.Position)
pos = rocket.Position
end)
Who knows how this works, XD ?