P
P
Pragma Games2021-07-06 18:11:33
Unity
Pragma Games, 2021-07-06 18:11:33

How to move a character relative to local coordinates?

I want that when I turn the joystick (Hold the button left or right) my character spins around its axis, with this code it just goes in one direction according to the world coordinates (Control should be the same as in any 3D third-person game). Initially, I thought that replacing the AddForce method with AddRelativeForce would solve this problem, but it turned out not to be so.

60e471e79cc06907148690.png

60e471f48aaf6163244784.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
AnanasikDev, 2021-07-11
@AnanasikDev

_moveVector = tranform.forward;
_moveVector += new Vector3(_joystick.Horizontal * _speedMove, 0, _joystickVertical * _speedMove);

PS: never, NEVER send screenshots of code. You should always throw the code itself to make it easier to edit it!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question