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 4 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

01local Rocket = game.Workspace.Rocket
02local Destination = game.Workspace.Destination      
03-- Variables
04 
05while wait() do
06    local Distance = (Destination.Position - Rocket.Position).Unit
07    local Direction = Rocket.CFrame.LookVector
08 
09    local NewRotation = Direction:Cross(Distance)
10 
11    Rocket.CFrame = Rocket.CFrame + Direction/3
12    Rocket.Orientation = NewRotation * 25
13 
14end

Answer this question