I have a simple 2D game for 2 players where they can pick some items up. How can I make an item spawn and as soon as one of the players picks it up (it thus gets destroyed on pick up) another item identical to that one spawns at a different location. Basically I want an apple to spawn here, player 1 picks it up, apple spawns further away and so on and so forth.
So, how can I check if the item had been picked up (or maybe destroyed?) so that I can call another SpawnActorFromClass node afterwards, in a sequence let’s say?
Do they play at one pc (local) or at two (mp)?
Generally, you can ask if sth is valid to know if the object is there. In your case, I would cast from the apple, which gets destroyed (before the destroy node), to the character and calls an event there to spawn a new one. Or you try to manage it at the character to destruct and construct a new one there.
you could have the apple spawn another just prior to its destruction or you could bind a event to the apple being destroyed as shown below. as for the location part you could just use a random offset to the previous location or use something like get random point in reachable radius.
I literally just made a tutorial about this EXACT thing haha. I used an event dispatcher to spawn the new item in. If you want a walk through of how to do this follow the link and scroll down to the last video “Event Dispatchers”.