I am making a submarine test for my game, and when you hold W it is supposed to move you forwards, I also have D and A as keys to rotate the submarine
However, as you see in the video, for some reason it is moving in the wrong direction (the correct direction is supposed to be the LookVector of the model)
Relevant Code (handles keybind processing):
local keybinds = {
W = function(down: boolean)
local movementMultiplier = 10
local damping = 0.2
local modelPivot = model:GetPivot()
local lookVector = modelPivot.LookVector.Unit
local rightVector = modelPivot.RightVector.Unit
if down then
cancelFuncs.W = moveAlongVector(lookVector*movementMultiplier, model, damping)
else
if not cancelFuncs.W then return end
isFinishing = true
local finished = cancelFuncs.W()
finished:Once(function()
cancelFuncs.W = nil
isFinishing = false
end)
end
end,
A = function(down: boolean)
local degreeIncrement = 10
local damping = 0.2
local modelPivot = model:GetPivot()
local lookVector = modelPivot.LookVector.Unit
local rightVector = modelPivot.RightVector.Unit
local upVector = modelPivot.UpVector.Unit
if down then
cancelFuncs.A = rotateAboutVector(Vector3.yAxis, model, degreeIncrement, damping)
else
if not cancelFuncs.A then return end
isFinishing = true
local finished = cancelFuncs.A()
finished:Once(function()
cancelFuncs.A = nil
isFinishing = false
end)
end
end,
S = function(down: boolean)
local movementMultiplier = 2
local damping = 0.2
local modelPivot = model:GetPivot()
local lookVector = modelPivot.LookVector.Unit
local rightVector = modelPivot.RightVector.Unit
if down then
cancelFuncs.S = moveAlongVector(-lookVector*movementMultiplier, model, damping)
else
if not cancelFuncs.S then return end
isFinishing = true
local finished = cancelFuncs.S()
finished:Once(function()
cancelFuncs.S = nil
isFinishing = false
end)
end
end,
D = function(down: boolean)
local degreeIncrement = -10
local damping = 0.2
local modelPivot = model:GetPivot()
local lookVector = modelPivot.LookVector.Unit
local rightVector = modelPivot.RightVector.Unit
local upVector = modelPivot.UpVector.Unit
if down then
cancelFuncs.D = rotateAboutVector(Vector3.yAxis, model, degreeIncrement, damping)
else
if not cancelFuncs.D then return end
isFinishing = true
local finished = cancelFuncs.D()
finished:Once(function()
cancelFuncs.D = nil
isFinishing = false
end)
end
end,
}
Feel free to ask for clarification, i am just very stumped on how to fix this