Question on passing attributes to actor
Hello all,
I am trying to figure out a good method to pass attributes from some actors to one other actor, and was wondering if anyone could point me in the right direction. Here's the deal:
I spawn and destroy numerous actors (of the same type) throughout the scene. Each actor has a constantly changing constrained attribute. I want to sum those constrained attributes and pass them to a different type actor who remains on the scene throughout.
I was considering sending the multiple attributes to a table (can you constrain a value in a table instead of changing it over and over?), summing them from the table, and having the destination actor pull that summed value into its own attribute. I am not sure if that will work, however, as I will be spawning and destroying a lot of these actors. I'm not sure how to tell each actor to have a unique row that they must update if I am adding and subtracting actors (and therefore rows of the table).
Any suggestions would be most appreciated!
Thanks,
AirshipScientist
Comments
Here's the technique I use to sync a spawned actor to a table row:
In the spawner actor, I use change attribute to change game.spawnOrder to game.spawnOrder+1 and then I spawn an actor.
In the spawned actor, I change self.spawnOrder to game.spawnOrder. I then use self.spawnOrder as the row value in any table expressions I use for the actor.
Table cell values cannot be constrained. The closest you can get is an every 0 seconds timer that uses a change table value behavior.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
@tatiang
I think you've answered a few of my questions now! Thanks again for the helpful advice.