Hello,
I am beginner at Unity programming. I have an problem with script that is resposible for moving object over game area, but these object are spawning every X secounds, so when I try to move one, every of them moves together.
Can anyone help me to move them separately, not all together? (2D game)
Thank you very much, Krzysztof
Post the code you have so far (use code tags ), and we can help you figure out how to modify it to work correctly.
Show us your code because if you are maintaining a collection of all spawned objects and just targetting one of them from this collection and telling it to move, only that one should move.
Is it like turn based movement?
Use an if statement to check weather the object the script is attached to has the permission to move this turn.
HIDDEN
This is my code for this game
I think you might be to broad in the touchCount any script asking in the update if the touch is greater than 0 will go… Maybe have a collider to accept an OnMouseDown() on the object to set it as active, script a bool set to true change if(Input.touchCount > 0) to if(bool == true) then when the target is reached clear the bool.
I deleted the if(Input.touchCount > 0) section, and the result is exactly the same as previously.
RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(touch.position), Vector2.zero);
This code work for me, but just partly. I can move only fresh spawned objects, other object are immeditally moved to spawn point.