G
G
Gregory2562022-02-19 07:09:35
Unity
Gregory256, 2022-02-19 07:09:35

How to make 2 objects move when interacting with one?

Good day, please tell me how to correctly move 2 objects in different directions at the same time when controlling one. Now I created a boolean variable in the script of one object and pass it to the second object through a singleton.

private void LateUpdate()
    {
        if (Input.GetKeyUp(KeyCode.W))
        {
            StartCoroutine(Move(0.1f));
        }
        if (isMooving == true)
        {
            StartCoroutine(Move(0.1f));
            if (isMooving == false)
                return;
        }
    }

When checking a variable in Update, the step length increases. Is there an idea to make movement through events, how appropriate is this?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question