How to disable touch if actor is behind the other actor?
Hello,
I have just found Gamesalad and so far it has been awesome!
I got a question related to actors on top of each other. I'm spawning actors to random locations and if touched they will die. The problem is with overlapping actors, for example if I have 3 actors over each other every single one of them will die if I touch the top most. Is there way to disable touch rule if an actor is behind other actors?
Hopefully that makes sense![:) :)](http://forums.gamesalad.com/plugins/emojiextender/emoji/twitter/smile.png)
Thanks!
-ww
I have just found Gamesalad and so far it has been awesome!
I got a question related to actors on top of each other. I'm spawning actors to random locations and if touched they will die. The problem is with overlapping actors, for example if I have 3 actors over each other every single one of them will die if I touch the top most. Is there way to disable touch rule if an actor is behind other actors?
Hopefully that makes sense
![:) :)](http://forums.gamesalad.com/plugins/emojiextender/emoji/twitter/smile.png)
Thanks!
-ww
Comments
I called the rule game.AITouched
When actor receives touch, change game.AITouched to true.
Otherwise: change game.AITouched to false.
my rule for selection was when actor receives touch &
When game.AITouched = false
Destroy Actor
I think I may have needed one more rule somewhere in there. I can't think of it at the moment, but if you find this doesn't get you on the right track, I'll try to explain further.
(the collide function)
hmmm..the collide thing might work...
Maybe a rule something like: if overlapping it checks the spawning time and compares the age of the actors and kills the youngest?
Back to solving this.. only if we had access to Z position, but I assume there is no such thing yet?
make an integer as a game.attribute, ima call it Game.SmashNumber
on your actor you want smashed, give it a self.attribute Integer as well. call it self.ID
then at the top of my actor I put 2 attribute behaviors:
Change Attribute self.ID to Game.SmashNumber
Change Attribute Game.SmashNumber to Game.SmashNumber +1
Also, if they are spawned, if you spawn "in front of actor" the larger number will always be in front. A combination of what I've suggested so far should get you on the right track.