Currently, I’m using a body gyro to rotate the model and a body velocity to move it.
My problem is in largely two parts.
One, the body velocity doesn’t move towards the orientation of the part (as in, it will continue to move straight forward even if the model is at an angel. https://gyazo.com/ca622088ad38a140929b6c6d22ccfc9b). I had figured the problem was (I think?) due to a body force inside of the root part, however this body force can’t be removed as it keeps the submarine from falling.
Two, how could I use body gyro to rotate the model horizontally? The x axis rotates my model vertically, while the Y axis doesn’t seem to move the model at all (again, probably because of the body force acting upon the y axis), while the z axis makes the model do a barrel roll. Should I be using body angular velocity instead to rotate my model? I had opted to use body gyro as I couldn’t figure out how to move the model in degrees with body angular velocity.
Local script
userInputService.InputBegan:connect(function(inputObject, gameProcessedEvent)
if inputObject.KeyCode == Enum.KeyCode.One and not gameProcessedEvent then
print("One")
SubRootPart.BodyVelocity.MaxForce = Vector3.new(10*144000, 0, 10*144000)
SubRootPart.BodyVelocity.Velocity = SubRootPart.CFrame.LookVector * 0
elseif inputObject.KeyCode == Enum.KeyCode.Two and not gameProcessedEvent then
print("Two")
SubRootPart.BodyVelocity.MaxForce = Vector3.new(10*12000, 0, 10*12000)
SubRootPart.BodyVelocity.Velocity = SubRootPart.CFrame.LookVector * 80
elseif inputObject.KeyCode == Enum.KeyCode.Three and not gameProcessedEvent then
print("Three")
SubRootPart.BodyVelocity.MaxForce = Vector3.new(10*24000, 0, 10*24000)
SubRootPart.BodyVelocity.Velocity = SubRootPart.CFrame.LookVector * 80
elseif inputObject.KeyCode == Enum.KeyCode.Four and not gameProcessedEvent then
print("Four")
SubRootPart.BodyVelocity.MaxForce = Vector3.new(10*48000, 10*48000, 10*48000)
SubRootPart.BodyVelocity.Velocity = SubRootPart.CFrame.LookVector * 80
end
if inputObject.KeyCode == Enum.KeyCode.W then
WHeld = true
elseif inputObject.KeyCode == Enum.KeyCode.A then
AHeld = true
elseif inputObject.KeyCode == Enum.KeyCode.S then
SHeld = true
elseif inputObject.KeyCode == Enum.KeyCode.D then
DHeld = true
end
end)
while wait(0.2) do
print(SubRootPart.CFrame.LookVector*80)
if WHeld == true then
SubRootPart.BodyGyro.CFrame = SubRootPart.CFrame * CFrame.Angles(math.rad(1), 0, 0)
elseif AHeld == true then
SubRootPart.BodyGyro.CFrame = SubRootPart.CFrame * CFrame.Angles(0, 0, 0)
elseif SHeld == true then
elseif DHeld == true then
end
end