Multiple Triggers controlling same Value
sparkania
Member, PRO Posts: 300
A problem I have been dealing with for 2 days now, I just figured out. Just thought I'd share the solution. (more experienced users will let out a collective "Duhhh")
I am building a platform game. and I have a decent amount of actors which I use as triggers to change a single value Spot(real) on the scene. This value will declare where my player is standing. This value will then be checked when the player performs an action, to see if that action is valid for that location.
I thought about using X and Y to do this but since I have 58 locations spread out over 7 height levels and those locations have separations between them where a '0' value should be given.. you might say I would still be typing in coordinates.
Anyway, I laid out all of my trigger actors and gave them all Collision conditions.
actor overlaps or collides with - actor of type - "Dude"
"Do"
Constrain Attribute
constrain: scene.Spot to:1 (a different number for each of the 58 spots)
So, this worked, but then I noticed that the value stayed even after Dude was no longer overlapping the triggering actor. I wanted the Spot value to return to 0 when the Dude was no longer overlapping it.
so first I tried putting in the Collision's "Else"
Constrain Attribute
constrain: scene.Spot to:0
but then half of my other triggers wouldn't change the Spot value anymore.. It was as if something was blocking triggers. It was absolutely driving me nuts. Then I tried putting the Else in all of the triggers.. still not working right. so after various combinations of various ideas.. I was frustrated.. and about to write a post filled with special characters about the math problems in GS..
Then I remembered something from layered programming in my day job..
Conditions in are read in a linear way, from first on the list to last.
I went through and erased all of the 'Else' conditions. Then I went to the Layers listing. I picked the bottom-most trigger actor, and put in an 'Else'
Constrain Attribute
constrain: scene.Spot to:0
and now it works like a charm because the return to 0 is commanded at the end.
I am building a platform game. and I have a decent amount of actors which I use as triggers to change a single value Spot(real) on the scene. This value will declare where my player is standing. This value will then be checked when the player performs an action, to see if that action is valid for that location.
I thought about using X and Y to do this but since I have 58 locations spread out over 7 height levels and those locations have separations between them where a '0' value should be given.. you might say I would still be typing in coordinates.
Anyway, I laid out all of my trigger actors and gave them all Collision conditions.
actor overlaps or collides with - actor of type - "Dude"
"Do"
Constrain Attribute
constrain: scene.Spot to:1 (a different number for each of the 58 spots)
So, this worked, but then I noticed that the value stayed even after Dude was no longer overlapping the triggering actor. I wanted the Spot value to return to 0 when the Dude was no longer overlapping it.
so first I tried putting in the Collision's "Else"
Constrain Attribute
constrain: scene.Spot to:0
but then half of my other triggers wouldn't change the Spot value anymore.. It was as if something was blocking triggers. It was absolutely driving me nuts. Then I tried putting the Else in all of the triggers.. still not working right. so after various combinations of various ideas.. I was frustrated.. and about to write a post filled with special characters about the math problems in GS..
Then I remembered something from layered programming in my day job..
Conditions in are read in a linear way, from first on the list to last.
I went through and erased all of the 'Else' conditions. Then I went to the Layers listing. I picked the bottom-most trigger actor, and put in an 'Else'
Constrain Attribute
constrain: scene.Spot to:0
and now it works like a charm because the return to 0 is commanded at the end.
Comments
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User