When Actor with tag "XYZ"'s Y-location is above "300"?
3absh
Member Posts: 601
It seems like something is missing here, I want to make a group of actors with the tag "Fruit Quarters" trigger a behavior when their "self" y position is over 300, is this possible?
Comments
Sure, here's a demo.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Thanks for the demo but what I meant was something like this:
Whenever an actor with the tag "Fruit Quarters" surpasses the Y position 300 then trigger the behaviour X
You used "self.tags" I need "game.actor.tags" if that is, it is possible, so that I only require 1 behaviour to trigger for a group of actors.
I'm thinking right now it's not the most efficient way to code, maybe that's the reason it's not featured.
Each actor has a tag attribute that corresponds to a global actor tag value set in the Actors tab in the Home view.
In my haste, I didn't copy the rule to all of the actors in the demo, but go ahead and do that... in essence, it's a single rule (or behavior as you wrote).
I'm not sure how what you want is different from that...?
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
I think the whole purpose behind the idea of tags should be to simplify codings.
Instead of copying the codes to 4 actors (or in my case 16) I could just say when something happens to an Actor with tag "bla" then trigger the behaviour "bla"
Yes, which is exactly how my demo functions. You can have 4 separate actors or a single actor with the same rule. And the rule itself says "when actor with tag 'bla' is at y > 300" then trigger a specific behavior.
You don't need to have four actors. I just did that for the sake of example. There's nothing to copy... you just add a rule that checks the actor's tag (which again is actually a global value).
The thing is: if you're using a single actor then you don't need to use tags. You just have a rule in the prototype actor and all copies of that actor will respond to the rule. Tags are for grouping multiple actors.
Edit: Hmm... I re-read your posts and I think I get it now. You want a single actor that checks all actors with tag "bla" to see if they are at y > 300. Is that correct? If so, then no, there isn't a way to do that from a single actor. Actors can't really sense other actors.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
In terms of efficient coding, if you knew that you needed 16 actors and that you wanted them to do something (a behavior) when y > 300 then you could create one actor with the rule from my demo and each time you need a new actor, you could then duplicate that actor and add any other rules you need. Of course, you'd have to manually add each actor (or all 16 at once) to the tags section in Creator.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User