O
O
Oleg_Lin2020-09-03 19:54:33
2D
Oleg_Lin, 2020-09-03 19:54:33

How to implement in Unity so that the head of a 2D character follows/follows the cursor?

How to implement in Unity so that the head of a 2D character follows/follows the cursor? Those. the player moves the cursor, and the head constantly looks in the direction of the cursor. I wanted to implement this through a bone in the skeleton for animations, but I did not figure out how to rotate the bone through the script. Tell me something.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Vodakov, 2020-09-04
@WaterSmith

It is necessary:
​​1. Determine the coordinates of the cursor.
2. Create a vector in the direction from the sprite coordinates to the cursor coordinates.
3. Rotate the sprite according to this vector.
Unfortunately, you didn't indicate which of these items you had difficulty with, which is why no one answers you for so long.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question