R
R
Robario2017-10-01 17:04:53
Unity
Robario, 2017-10-01 17:04:53

Managing GG with a wheelbarrow?

Task: to organize the management of the GG with a finger.
I was only able to do this:

if (Input.GetMouseButton(0))
                    {
                        Vector3 mousePosition = MainCamera.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, MainCamera.transform.position.y));
                        _rb.MovePosition(new Vector3(mousePosition.x, 0.0f, mousePosition.z));
                    }

GG moves to the point of pressing and follows the finger.
It is necessary that the GG does not move to the touch point, but moves parallel to the movement of the finger across the screen.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex Maximovich, 2017-10-01
@Robario

You need to take the delta between the moment the screen is touched and the current position of the finger and add this delta to the current position of the character.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question