- Home /
How do I make a game object spawn and then stay and move up when mouse is cilcked?
I am currently making a game and I want a game object to spawn on a certain point and stay on that position and then move up when the mouse is clicked. I want the game object to spawn a new one when the current game object has already moved and not spawning continuously. Thanks!
Answer by hexagonius · Oct 31, 2018 at 07:55 AM
use instantiate to spawn a prefab where you want it. use OnMouseDown to receive a click event and propagate it to the prefab instance. run a check that confirms the original prefab instance has moved to instantiate a new one.
for everything else:
https://unity3d.com/de/learn/tutorials/topics/scripting/coding-unity-absolute-beginner
Your answer
Follow this Question
Related Questions
Help? Im trying to get my zombie prefab to spawn, but stop them spawning after a set spawn limit. 1 Answer
mouse click obj to initiate action, then locking the obj so action cant be repeated 1 Answer
MouseClick and gameObject 1 Answer
Spawning help 1 Answer
Network player duplicated when replacing player with a new one 1 Answer