Clicking top actor only when overlapping another actor.

Asobu_GamesAsobu_Games PRO Posts: 261
edited November -1 in Working with GS (Mac)
Hi guys (and girls). I have been trying to solve this issue for an hour or 2 with no success. (-_-) I've searched the forum but can't find a specific solution.

Basically I have a 'shooting gallery' style game where you click/tap an actor to destroy it. If it's a 'bad guy' you also get points. If you tap a 'good guy' you lose a life. The actors spawn in random positions meaning occasionally they overlap. I'd like to make it that if you click the top actor they will disappear (and you'll get points or lose life) WITHOUT registering a hit on the actor behind. At the moment both actors disappear.

I have tried creating an index attribute and assigning actor numbers to each actor but can't seem to get it to work. I also tried an 'otherwise' rule for when actor is not overlapping another. I must be doing something wrong! Any help would be much appreciated. Please be as detailed as possible as I am new to GS.

Comments

  • DoManDoMan Member Posts: 102
    This may be a bit basic, go inside the actor that SPAWNS your little actors. Set the layer of that to the top. In the spawn BEHAVIOR set the GOOD to "Behind Actor". Set the bad guys to "ABOVE LAYER". This basically adjusts if the actor spawning should stick the dude in front of himself, or on top of him.
  • Asobu_GamesAsobu_Games PRO Posts: 261
    Thanks DoMan :) I'm not sure if this makes a difference though? Regardless of which actor is on top or behind, both will get destroyed at the same time with a single click. I only want one actor (the top one) to register a click during an overlap. I'd like to make the one that is behind have some kind of rule like: if this actor overlaps/collides with another actor, don't register the click/hit. Sorry if my explanation is confusing!
  • DoManDoMan Member Posts: 102
    No, i get it!
    Try this - make a boolean attribute (one that is on, off) in the "game" section, when you click on the baddy actor, it changes that attribute to false. And quickly after that, (using an "after" (of about 0.1 seconds) timer on "run to completion") set that attribute back to true.
    NOW - on the goody actor, set that it can only be "shot" if the attribute is true. That way there is a tiny gap where the goody is not hurt while the baddy one is being "shot".

    Hope this isn't too confusing, just reply and ask if i need to slow down for extra slow-mo help.
  • RHRH Member Posts: 1,079
    http://gamesalad.com/g/3279

    I think this is what you mean.

    you can download the project file by searching for it in the GameSalad creator
  • Asobu_GamesAsobu_Games PRO Posts: 261
    I'm getting there DoMan :) Thanks for the help. I tried the boolean attribute method and I succeeded in getting the top actor only to register the hit, however the attribute doesn't seem to switch back to false after hitting the baddie, as then the goodie won't register a hit at all any more.
  • Asobu_GamesAsobu_Games PRO Posts: 261
    *EDIT* I looked again and it seems that it is switching back to flase, but it's taking quite a while (about 5 seconds) despite having a timer set to 0.1 sec. Maybe a timer problem, but I can't think why it wouldn't run to the specified timer. Any ideas?
  • Asobu_GamesAsobu_Games PRO Posts: 261
    FINALLY SOLVED THIS!! :)

    My problem was that the bad guy actor was controlling the boolean attribute (to true), but the same actor was being destroyed instantly when clicked before it had a chance to perform the switch back to false. So instead of destroying the actor instantly I made it disappear (alpha = 0) when clicked, then changed the boolean attribute to true > false for a split second, THEN destroyed the invisible actor a split second later. Working fine now.

    Thanks so much for the help! :) I really appreciate it!
Sign In or Register to comment.