F
F
fauron2021-07-30 15:01:58
Unity
fauron, 2021-07-30 15:01:58

When I run the project, the player model only goes to the right, how to fix the code below?

private void Run()
    {
        Vector3 dir = transform.right * joystick.Horizontal;       
        transform.position = Vector3.MoveTowards(transform.position, transform.position + dir, speed * Time.deltaTime);   
    }

How to fix the code, the model is controlled by the joystick, regardless of the side where the joystick is directed, the model goes to the right

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikita Polishchuk, 2021-07-30
@PNECtarine

Well, try to make a Vector3 field, pass the direction coordinates to it and add them to the character's current position

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question