BodyPosition is going in a weird direction that was not intended

Hi, so I’ve made this simple warp system similar to that of the Galaxy game on roblox. However, there’s a problem in which the ship would go in some weird other direction, rather than the “front” of the ship.

Here’s what I mean

Here’s my code related to it:

local pos = ship.PrimaryPart.CFrame.LookVector * distance

local warpBody = Instance.new("BodyPosition")
warpBody.Parent = ship.PrimaryPart
warpBody.P = 1250
warpBody.D = 300
warpBody.MaxForce = Vector3.new(1,1,1) * math.huge

wait(0.1)
warpBody.Position = ship.PrimaryPart.CFrame.LookVector * distance

I simply do not know why this happens, it’s so confusing…

What have you tried?

  • I’ve set the “front” of the ship to the actual front of the ship
  • Visualizing it with a brick. Displayed it in the same opposite direction.

It may be that you have the max force set to Vector3.new(1,1,1) when you want it to go foward correct?

I set it to Vector3.new(1,1,1) x math.huge, so it’d be the equivalent of Vector3.new(math.huge, math.huge, math.huge)

yes but you want it to just move foward?

Yes, relative to the ship’s front direction

x/z would be foward movement depending on the direction of which they are facing.

This is the problem. You’d want to apply this to the existing position by for example changing the operator to +=. The lookvector is a unitvector describing a direction and not a position, and distance is a scalar.