How to disable touch if actor is behind the other actor?

wurwagwurwag Member Posts: 16
edited September 2012 in Working with GS (Mac)
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 :)

Thanks!

-ww

Comments

  • 3itg3itg Member, PRO Posts: 382
    edited September 2012
    I made an actor, and made a rule that changes a boolean to true while touched.
    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.
  • ultimaultima Member, PRO Posts: 1,207
    edited September 2012
    try, if collide "touch" xxx actor...

    (the collide function)
  • wurwagwurwag Member Posts: 16
    Thanks @3itg and @ultima.
    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?
  • 3itg3itg Member, PRO Posts: 382
    you could set up the "age" thing like this (lowest would be oldest):
    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.



Sign In or Register to comment.