Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Cross Product working really weird?

Asked by 3 years ago

After wanting to make a homing missiles I did some research of my own and found out that Cross Products would work well with homing missiles if you don't want it to automatically point to a target. After some testing I realized I don't know vector math and am confused someone help, I tried to make the missiles slowly aim to the destination but it ended up barely scratching it and going to some other place and if I placed it further it would slow down the rotation speed even though it wasn't even close to being aligned to the destination, here is the code I made so far

local Rocket = game.Workspace.Rocket
local Destination = game.Workspace.Destination       
-- Variables

while wait() do
    local Distance = (Destination.Position - Rocket.Position).Unit
    local Direction = Rocket.CFrame.LookVector

    local NewRotation = Direction:Cross(Distance) 

    Rocket.CFrame = Rocket.CFrame + Direction/3
    Rocket.Orientation = NewRotation * 25

end

Answer this question