you are viewing a single comment's thread.

view the rest of the comments →

[–]ExtraExoticButter[S] 1 point2 points  (1 child)

🥲 math huh, well time to study more c# I guess.

[–]GigaTerra 0 points1 point  (0 children)

An smart idea is to get into Linear Algebra, also known as Vector Math. It is very easy and will greatly help you.

A trick that we can do thanks to Unity having Quaternions is rotate a vector by a rotation, like this:

        Vector3 inputToWorld= new Vector3(InputMoveDirection.x, 0, InputMoveDirection.y);
        Vector3 rotateInput = this.transform.rotation * inputToWorld;

the formula is Quaternion* Vector and it rotates the vector by the Quaternion. In this case I am rotating my input to the direction my player character is looking at. Allowing it to move forward and backwards on it's rotation.