Destroy actor if not colliding/overlaping with another actor

PimanPiman Member, PRO Posts: 165
edited January 2012 in Working with GS (Mac)
Can anybody tell me how to do this sensibly? I can't get it to work. I am trying to have player controlled Actor X be destroyed as soon he doesn't overlap with Actor Y anymore.

How I tried:

Make a real attribute called "alive".
Have it be 1 by default.

Make a rule in Actor Y that makes sure attribute "alive" is 1 when it collides with Actor X(he starts on top of it).
Have "otherwise" change attribute to 0.

Have actor X contain a rule that if this attribute is 0, the actor is destroyed.

It doesn't work...

Comments

  • POMPOM Member Posts: 2,599
    edited January 2012
    Hey ,
    In theory this should work , so we need to figure out what's went wrong in the code..
    What is the collision type of your actors? circle? rectangle?
    Does your actors have art with transparency around it?

    in you X actor , put a "display text" behavior to see the value of the "alive" attribute , is it going to 0 once they DONT overlap ?

    Roy.
  • PimanPiman Member, PRO Posts: 165
    I used the display text trick and I tried it also in another project - what I saw is the "alive" tribute somehow remained unaffected. I have been trying to solve things myself for several days now and I'm becoming a bit desperate.

    This seems such simple game logic but I can't get it to work. I hope it's just me missing something here.

    Actor X is PNG with some transparency but in all other collisions it is working fine.
    Both have rectangle collision.
  • POMPOM Member Posts: 2,599
    Make sure that in the otherwise section of your collision rule, you change the "alive" value to 0 !
    Still dosnt work , post an image of you rules so we can take a look ..

    Roy.
  • PimanPiman Member, PRO Posts: 165
    edited January 2012
    http://imageshack.us/photo/my-images/217/screenshot20120111at330.png/ Actor X

    http://imageshack.us/photo/my-images/252/screenshot20120111at332.png/ Actor Y



    I tried change/constrain attribute , I tried having the value 0 or 1 by default (game attributes), I tried having actor X overlap with Y at the beginning or not...
  • POMPOM Member Posts: 2,599
    Two things i can think of ..
    1) you have another "spark" actor in the scene , maybe you opened an instance , check it !

    2) something else is using the "alive" attribute , to check what actors using it , go to your game.attribute list , and select the "alive" attribute ,
    Then hit the "-" (minus) sign like you want to delete it , a pop up message will come and tell you the actors that using this attribute (DONT REALLY DELETE IT)
    Check the actors that using it and press "cancel"

    Roy.
  • PimanPiman Member, PRO Posts: 165
    I checked all those things....

    No other instances of actors, no other actors playing around with the attribute...

    I seem to have such problems constantly.. where the logic dictates something should work but it doesn't..
  • SingleSparqSingleSparq Member Posts: 1,339
    I've never got this type of thing to work. Its like it can only register collide/overlap but not a 'Im not touching anymore' instance - a bug perhaps?
  • PimanPiman Member, PRO Posts: 165
    Well, very annoying. I am stuck for days now due to various odd behaviors like this in practice that seem to defy the sound logic in theory. I hope there is somebody out there that has a solution.

  • POMPOM Member Posts: 2,599
    edited January 2012
    Does at least one of your actors are movable?
    In order to register collision between 2 actors at lease one of the must be movable .
    Roy.
  • PimanPiman Member, PRO Posts: 165
    Yes, Actor X is moved by touch and actor Y as you can see in the rules starts moving as soon as Actor X is touched...

  • POMPOM Member Posts: 2,599
    edited January 2012
    No mate , i ask is its attribute movable is on? enter your actor , and on the left , in his attributes :
    physics -> movable , is it checked?

    At least at one of them must be checked on to register collision .
    Roy.
  • PimanPiman Member, PRO Posts: 165
    Actor Y starts moving as soon as Actor X is touched if Actor Y wouldn't have movable checked it wouldn't move - so yes both have "movable" checked.

    Thanks for your help though, I am open to suggestions. I feel like I have to try some other game, though I am a bit frustrated because I will be switching project again because seemingly there are bugs in GameSalad I can't overcome.

  • POMPOM Member Posts: 2,599
    Don't give up so quickly , this stuff happens all the time ..
    do you want to send me the project so i take a look ?

    If so , you may send to roysadaka (at) gmail (dot) com
    :D
    Roy.
  • PimanPiman Member, PRO Posts: 165
    Ok..
  • PimanPiman Member, PRO Posts: 165
    Just sent it. And I am not giving up and if I did I am not sure if it'd be quickly - I've made various test games and I have been sitting long hours to solve these problems. At first I thought I was too much of a newb and should figure them out, but they just seem bugs. Beside this problem I have a few others bugging me.
  • POMPOM Member Posts: 2,599
    edited January 2012
    Got it ,
    First , i immediately found a conflict ,
    see :
    image

    You tell your actor to destroy if he collides with actor Y , and to destroy if "alive" is 0 (not colliding) so either way its gonna be destroyed .
    im not sure what effect you want to achieve , maybe be more informative..

    Also , I've fixed the file you sent me , i just sent you back the fixed project.

    Roy.
  • PimanPiman Member, PRO Posts: 165
    Well I tried a whole lot of versions but apparently the self.time > 1 was needed to omit the bug in GameSalad like you wrote me by e-mail.

    The effect I wanted to achieve was simply to keep actor X alive as long as he was overlapping with Actor Y
  • PimanPiman Member, PRO Posts: 165
    By the way there is no conflict, the enemey is not Actor Y but another actor.
Sign In or Register to comment.