Track number of spawned objects?
-
I have a few different characters that are spawned during the game. I want to add a behavior that tracks the number of spawned characters and triggers an event once the number of spawned pass a certain number. Any idea how to do this?
-
@This you could use any of the multiple storage behaviors, such as box containers, attributes, etc. and when you spawn, just add 1. Then you connect an "if" and check to see if the added number is equal to the number you want to trigger behaviors at. The you could use the "execute behavior" behavior to trigger the behaviors.
-
@iTap-Development Thanks for this. I'm having trouble finding any documentation on how to us these behaviors. Any tutorial recommendations you know of?
-
@This here are two pictures of how this could look! It would probably be easiest to follow the second picture with box containers.
-
@iTap-Development Thanks for this! Very helpful. One follow up question. Is it possible to have values deposited into the box from various objects? I have three different creatures that are spawned. I want to have the behavior executed when the aggregate of them passes a certain count.
-
@This
Box containers are pretty much contained within that object.If you want to have a more "public" value that can be change by other objects use attributes instead.
You can create an attribute on an object, then use set attribute from any other object to set the attribute (in this case increase) for the object. -
@This if you do attributes, you'll have to remember to select the object that you created the attribute on if you want to change the attribute from another object.
-
Thanks all! I'm messing around with attributes, but don't seem to be able to crack it. Any chance you could post a screen grab of how this would be done with attributes?
-
@This my first pic is for doing it with attributes.
-
@iTap-Development I don't know if this goes for anyone else, but I see no picture. Here's mine:
If more than one object is spawning what you want to count or the counted objects can delete themselves, use attributes and make sure they all select the same attribute from the same object, otherwise you could use either attributes or box container. -
-
Thank you all!