my part fall like this* 30longchar
You can use CFrame.lookAt
and AssemblyLinearVelocity
.
local part: BasePart
local cframe = CFrame.lookAt(part.Position, part.AssemblyLinearVelocity + part.Position)
3 Likes
I agree with @busterbob64’s approach to for obtaining the desired CFrame and I would tilt the object towards its direction of motion with a BodyMover.
task.spawn(function()
while task.wait() and start do
missile.missile.CFrame = CFrame.lookAt(missile.missile.Position,missile.missile.AssemblyLinearVelocity+missile.missile.Position)
end
end)
It doesn’t work for me
Nothing changed
task.spawn(function()
game:GetService("RunService").Heartbeat:Connect(function()
missile.missile.CFrame = CFrame.lookAt(missile.missile.Position,missile.missile.AssemblyLinearVelocity+missile.missile.Position)
end)
end)
If you are using the CFrame to create the animation, then you can use the previous position to calculate the direction in which your object should look
task.spawn(function()
local prevPosition
while task.wait() and start do
prevPosition = missile.missile.Position
missile.missile.CFrame = -- your position calculation
missile.missile.CFrame = CFrame.lookAt(missile.missile.Position, prevPosition)*CFrame.Angles(0,math.pi,0)
end
end)
task.spawn(function()
local last_position
while task.wait() and start do
last_position = missile.missile.Position
missile.missile.CFrame = CFrame.lookAt(missile.missile.Position,last_position)*CFrame.Angles(0,math.pi,0)
end
end)
It just disappeared when I test it
this is my full code:
local missile = workspace.missile
local stuff = game.ReplicatedStorage.missile.stuff
local start = false
task.wait(4)
missile.missile.missile_fire:Play()
missile.missile.Anchored = false
missile.missile:ApplyImpulse(Vector3.new(0,500000,500000))
missile.missile.missile_fly:Play()
start = true
task.spawn(function()
local last_position
while task.wait() and start do
last_position = missile.missile.Position
missile.missile.CFrame = CFrame.lookAt(missile.missile.Position,last_position)*CFrame.Angles(0,math.pi,0)
end
end)
task.spawn(function()
while task.wait() and start do
local cloned_stuff = stuff:Clone()
cloned_stuff.Parent = missile.missile
cloned_stuff.CFrame = missile.missile.CFrame
end
end)