integers and actors
belotte
Member Posts: 25
Does any one know if it is possible to attach an integer to a spawned actor?
Thank you
Richard
Thank you
Richard
Best Answer
-
gyroscope I am here.Posts: 6,598
Hi gyroscope.
OK, I misunderstood what you wanted to achieve.... hopefully @FryingBaconStudios suggestion will sort it for you.
Thanks, but that wont work. Reason being that the spawned actors at the bottom actually swap to a new actor. So there's in essence, nothing to count as every time it is starting over with a new actor.
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
Answers
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
Or if you don't know what the correct terms are then try and describe what it is you are trying to achieve.
So Atributes (like an integer) are "generic", meaning that once created they are global (any rule on any actor can reference them).
Is it posible to create an atribute (again... an integer in this case) that is local; meaning it can only be referenced by the rules of one actor.
That's what I mean by "attached". Does that make sense?
Thanks,
Richard
can I assume you are wanting a single actor to be Spawned and use an attribute (integer) which you are not seeing when programming the Prototype?
@belotte
Hi Richard, yes, as @sparkania confirmed, you can make an attribute specifically for any one actor; in GSC, these are called self attributes.
Some info "for the record": there are three types of attributes that can be made in GSC, namely game attributes, scene attributes and self attributes.
• Game attributes are the equivalent of global variables in something like RealBasic, etc., as you mentioned global. So even when changing scenes, these will be "remembered".
• Scene attributes are specific to each scene and are the equivalent of a type of local variable made in RealBasic, etc. These don't stay in the memory when moving to another scene, so you can easily have exactly the same type of scene attribute with the exact same name for every scene if you wanted, but all with different values, if required.
• Self attributes are specific to an actor in a particular scene, and are equivalent to local variables; these are made in the prototype actor in the Inspector, then the value can be changed to suit, once it has been dragged out onto the scene. And like scene attributes, the values of self attributes don't stay in memory if you change scene.
Hope that's useful for you.
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
OK that's good to know. Unfortunately that doesn't really help. What I need is an atribute (variable) that is associated with just one spawned actor but can be referenced by another actor.
Let me explain what I am trying to do. I have actors that are spawned randomly at the bottom of the screen. Each of those individually has 3 stages. So it spawns and stays in the first stage.
Now, there are actors that are randomly spawned at the top of the screen. When you "click" these, they "shoot" a "beam" down to the actors at the botom.
If this "beam" hits an actor at the bottom of the screen,the actor at the botom swaps to a new actor; putting it in the next pase of the 3. And then all this again for the third and final stage.
The problem I have is I cant get the actor at the botom to stop at each phase. On first contact the actor at the bottom progresses straight through the second fase to the last.
Does that make sens?
Thanks,
Richard
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
Thanks for the idea. In theory that works... but there's a problem with that. When the beam hits the actor, it "switches" to a ne actor (second in the sequence), so any self atribute (the intiger in this case) is gone with the previous actor.
Hi @belotte
Here's another test for you which you can hopefully incorporate the principals into your game. I've made the equivalent of the laser beam draggable for this example. And I've dragged out the prototypes instead of having them spawned, but spawning them it will still work the same way. And I've made a self attribute called Counter in the prototype actor, which decreases by one in each individual copy of the prototype, every time the laser actor touches it.
Prototype self attributes test:
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
Thanks, but that wont work. Reason being that the spawned actors at the bottom actually swap to a new actor. So there's in essence, nothing to count as every time it is starting over with a new actor.
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
The count up with an integer (self attribute) didn't work. Still the same problem.
What did work though is that in conjunction with a global Boolean.
YEAH!