Destroy actor if not colliding/overlaping with another actor
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...
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
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.
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.
Still dosnt work , post an image of you rules so we can take a look ..
Roy.
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...
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.
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..
In order to register collision between 2 actors at lease one of the must be movable .
Roy.
physics -> movable , is it checked?
At least at one of them must be checked on to register collision .
Roy.
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.
do you want to send me the project so i take a look ?
If so , you may send to roysadaka (at) gmail (dot) com
Roy.
First , i immediately found a conflict ,
see :
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.
The effect I wanted to achieve was simply to keep actor X alive as long as he was overlapping with Actor Y