How should I get the relative facing direction of camera?

Hi! I am working on this tank movement that allows player move forward by pressing W key when camera is looking at the forward of the tank. The player can move backward also by pressing W when camera is looking at the back of the tank. I need to find a condition to set the forward vector to negative. But I am struggling to find that condition, the condition by checking camera forward vector will be affected by tank’s own rotation… Please help me out!

Use DOT product between camera forward vector and tank rotation forward vector, if result is negative then you want to go backwards.

Something like this

1 Like

Thank you! That works for me!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.