Make a missile fly level towards its target

Hey All,

I have a missile that flies, but does so in a vertical position. The missile is scripted to follow a spacecraft using BodyPosition placed in a part in the center of the missile. I tried to correct the problem by using CFrame to have the center part face towards the spacecraft using the script line:

orientationPoint.CFrame =, spacecraft.Position)

It didn’t work. Any thoughts on how to level out the missle?
Here is the full movement script for the missile:

-- Moves the rocket to a desired position

local orientationPoint = script.Parent.MissileSpawn
local bodyPosition = script.Parent.Center.BodyPosition
local spacecraft = game.Workspace.ParkerShip3.SpaceFrame

while true do
  local spacecraftPosition = spacecraft.Position
  bodyPosition.Position = spacecraftPosition
  orientationPoint.CFrame =, spacecraft.Position)

Here is a video of the missile chasing the spacecraft. The big yellow sphere is the part that will register contact between the missile and the spacecraft; visible only while I work on it. The grey brick on the side of the sphere is to help me orient which side of the rocket was facing the spacecraft. To be removed once complete.

robloxapp-20210225-1955508.wmv (732.0 KB)

Any thoughts?

1 Like

Looks to me like it just needs to be rotated by 90 degrees, so one of these 3 should work:

orientationPoint.CFrame =, spacecraft.Position) * CFrame.Angles(math.pi * 0.5, 0, 0)
orientationPoint.CFrame =, spacecraft.Position) * CFrame.Angles(0, 0, math.pi * 0.5)
orientationPoint.CFrame =, spacecraft.Position) * CFrame.Angles(0, math.pi * 0.5, 0)

You were on the money! Your first suggestion line worked, just adding a negative to the 0.5. Thanks!

Here’s a video of the correction:
robloxapp-20210225-2027035.wmv (1.6 MB)