V
V
vgrebennik20152017-01-03 15:12:20
Unity
vgrebennik2015, 2017-01-03 15:12:20

How to implement the movement of an object on the cursor?

Hello! I'm making a game like agar.io. I got stuck on the first one: it is necessary that the object moves in the direction of the cursor, and the camera moves along with it. Has anyone done this? Went through the floor of the tyrnet and did not understand anything.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Espleth, 2017-01-03
@vgrebennik2015

In my opinion, you started making a game early, stuck on a simple one. Better read more tutorials, otherwise you will run here for every slightest question.
If you still ignore the advice above:
Input class - https://docs.unity3d.com/ScriptReference/Input.html , you will find how to get the mouse position there. It's strange that you went through the floor of the Internet, since you did not find it.
The easiest option is to make the camera a child of a moving object - if this is also not obvious, then you have certainly started writing your game.
And I suggest reading how to move an object in the Transform class https://docs.unity3d.com/ScriptReference/Transform.html
Well, or apply force through Rigidbody2D https://docs.unity3d.com/ScriptReference/Rigidbody...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question