I have a part that orbits another part. However, problem is it doesn’t rotate to face the direction it’s moving in, and just faces a constant direction
I want it to face towards where it’s moving
local OrbitCFrame = CFrame.new(
math.sin(Rotation) * RADIUS,
0,
math.cos(Rotation) * RADIUS
) + building:GetPivot().Position + Vector3.new(0, Size.Y / 2, 0)
part.RootPart.AlignPosition.Position = OrbitCFrame.Position
--// below
part.RootPart.AlignOrientation.CFrame = CFrame.lookAt(
part.RootPart.Position,
OrbitCFrame.LookVector
)
Get the current location and the next location. Then, you can use CFrame.lookAt
to make it look at the next location:
local currentLocation = --> current location
local nextLocation = --> next location
local cf = CFrame.lookAt(currentLocation, nextLocation)
This works because lookAt
returns a CFrame
positioned on the first argument and rotated towards the second argument.
2 Likes
To me I think I would just keep the the part looking at the center so when it rotates its facing the direction where it should rotate.
I would do this then just rotate it 90 or 270 degrees depending on if its moving clockwise/counterclockwise.
That’s not what I want tho. I want it to look in the direction its moving. Would look off facing the part its rotating around
So I made a simple rotation with a model.
local part1 = workspace:WaitForChild("Orbit"):WaitForChild("Part1")
local part2 = workspace:WaitForChild("Orbit"):WaitForChild("Part2")
local part3 = workspace:WaitForChild("Orbit"):WaitForChild("Part3")
local part4 = workspace:WaitForChild("Orbit"):WaitForChild("Part4")
local center = workspace:WaitForChild("Orbit"):WaitForChild("Ceneter")
script.Parent.PrimaryPart = center
while wait() do
script.Parent:SetPrimaryPartCFrame(center.CFrame * CFrame.fromEulerAngles(0, 0.01, 0))
end
It seems that this is the kind of out come you want, though I’m not sure if you want this kind of method. Just set the transparency of the center to 1.