How to spawn an object on button click and make it follow the mouse until left click?
The game I am working on is 2D, so all sprites are 2D.
I have several UI buttons that when clicked on, will set a certain sprite (It will not spawn in to the game), and then I can click anywhere else on the screen with the mouse to spawn that sprite at the location of the cursor, and that sprite will stay there. This can be repeated by clicking on one of the buttons again and so on.
However, I need the object to spawn when I click the button, but it will follow the mouse, until I left click, in which case the sprite should stay where ever I left clicked. And I can repeat this by clicking one of the buttons again.
Is there a way to do this?
Your answer
Follow this Question
Related Questions
Player follows mouse, but I need only Y 1 Answer
Hey Guys How to make a script '**private Transform Waypoint;**', 0 Answers
Camera Following [2D] 2 Answers
[Editor Extensions] - Rotate object in editor mode 0 Answers
Mouse follow help 0 Answers