Can One Actor Set/Read Another Actor's Attributes?
netdzynr
Member Posts: 296
Like the title says, is it possible for one actor to set or read another actor's attributes, without relying on global game attributes?
I have a scene with 36 actors, each of which can be set to 1 of 3 "states". I want to somehow query the states of all 36 actors and compare them to a stored master state. The problem is, I don't want to have 36 game attributes each tracking the actor states -- this will get messy quickly as this is only one scene in the game, and the game will have multiple scenes.
Alternatively, I see that Scenes can have custom attributes applied, but how the heck do you read/write to them? The options in the Attribute Browser only seem to list options for the Game, not the Scene.
(Arg, I wish the GameSalad folks would update their development app already.)
Thanks for any suggestions.
I have a scene with 36 actors, each of which can be set to 1 of 3 "states". I want to somehow query the states of all 36 actors and compare them to a stored master state. The problem is, I don't want to have 36 game attributes each tracking the actor states -- this will get messy quickly as this is only one scene in the game, and the game will have multiple scenes.
Alternatively, I see that Scenes can have custom attributes applied, but how the heck do you read/write to them? The options in the Attribute Browser only seem to list options for the Game, not the Scene.
(Arg, I wish the GameSalad folks would update their development app already.)
Thanks for any suggestions.
Comments
http://gamesalad.com/forums/topic.php?id=4065#post-24062
As far as scene attributes, only instances in the scene have access to them. I use a "scene controller" actor, which is just a simple box with no code. I place this actor in the scene but outside of the viewing area. Double click on this actor to set its instance behaviors (click the padlock). This actor now has access to things like the camera, and can set scene-specific attributes like the current level and the number of bombs for this level, etc. Those are global game attributes though. Whenever i need to reset a level, this actor takes care of resetting all the attributes.
It could open up some doors in sticky situations I suppose.
But if you can get by using the usual method (i.e. the one you outlne above), maintenance will be easier (for now).
* I hate saying "for now" and "at this moment" but being in Beta, I would hate for folks to read the old forum posts and think things were one way when they end up being another way down the road. Oh heck!
Given the responses above, I think I'm going to set up 50 or so generic game attributes that are reused in each level. It's tedious to set up, and a pain to write rules for checking them, but "currently" (following your lead here) there doesn't appear to be any other option.
This is almost as good as having arrays! Thanks guys!
As always, experiment and test (on multiple devices).
http://gamesalad.com/game/play/48416
I took individual actor attributes (for example: 'A', 'B', 'C', 'A' and 'B'); concatenated them ('ABCAB'); and then used a rule to compare it to the actual combination ('ABCBA').
(I only used five actors instead of thirty-six but it's scalable, I think.)
Was this something like what you were thinking?
In my arrangement, there are only 2 actors with custom behaviors for any number of "keys": the prototype actor, and a "scene manager" that keeps track of the instanced actors' values.
So yes, I believe your setup is scalable, but requires some careful planning. Who knows, I may fall back on this method if I run into some issue with my direction.
(The bottom line is, I think we all know the GS options for setting/getting variable values are in need of a significant update.)