Can you link actors without using global variables?
Is there any way to pass variables between two actors without having to set a global variable? I am trying to keep my variables to a minimum, but I would like to pass certain values from one actor to another. Really, I am spawning characters of the same "type," but who have different attributes. In most cases, the spawn can be instant and I can hide it until it is ready, but I have a few f(x) that don't run right away. Those f(x) pick up the wrong amount saved in the variable for another actor.
I know I can save them to global variables and pass them that way, but I am trying to avoid keeping a bunch of global variables that I don't need. Anyone have any suggestions?
Thanks!
C
I know I can save them to global variables and pass them that way, but I am trying to avoid keeping a bunch of global variables that I don't need. Anyone have any suggestions?
Thanks!
C
Best Answer
-
tatiang Posts: 11,949
It depends a lot on how you need to use those attributes. If you are spawning actors, then the only way to pass attributes is with global (game.______) attributes. If you recycle actors by keeping them off-screen until needed and then moving them (change attribute self.position.x/y to...) to an on-screen position, you can unlock the actors and access the Current Scene-->Layers-->[layer name]-->[actor name]._____ attributes.New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Answers
If an actor is unlocked, I believe that you go to current scene > layers > (layer object is in) > object > (the self.attributes are there).
That order might be wrong. I'm on a PC now so I can't check.
Since you are spawning actors they won't be unlocked though...
Hope this helps,
Jack McGraw