WASD movement giving buggy movement

Hello, I am trying to add wasd movement to a mesh but so far have been unsuccessful in getting it to work properly. I want the WASD movement to work in that the submarine moves while rotating as well. Currently the sub can rotate and move forwards and backwards but when it is rotated at a 90 degree angle to the left and right it suddenly won’t move forward.

What I am trying to achieve is something like this but at lesser movement speed:
https://www.babylonjs-playground.com/#Y2XX5A

Here is my playground I am working on:
https://www.babylonjs-playground.com/#165IV6#1016

The animation code is at the bottom

I had to use the right Vector instead of the Forward because of the orientation of the sub.
https://www.babylonjs-playground.com/#165IV6#1022

2 Likes