Question about "overlaps or collides" rule
Hey guys! I have a question about the "overlaps or collides" rule. Basically, I have a setup where I want to check the type of several different randomly spawned actors in my scene. The actors don't move, so I know where they will be, but for my game I need to know what type they are.
So, starting off, I was spawning and destroying "check-er" actors in all of the possible places where the randomly spawned actors could be, and had a rule that stated: if you overlap of collide with one of these guys, change attribute - count +1. This way I could count up how many of each type were in the scene at specified times.
I knew that spawning and destroying actors was going to be bad for performance, but I did it just to see if that type of behavior worked. And it did. It worked great. Of course my performance sucked, but I got the desired results.
So I decided to optimize it by getting rid of the spawning behavior and instead, just moving the the "check-er" actor from position to position. I figured I would get the same result. I did not. It seems that the "overlaps or collides with" rule is a one shot rule. As soon as my "check-er" hits a type of actor he is supposed to count, he counts up +1 (like he is supposed to do), but when he hits a second one, he does nothing, and the count stays at 1 forever.
Is there anyway to set these rules to NOT be one-shots? As in, EVERY TIME he hits a new actor of the same type, he counts +1.
Here is an example of my script:
rule - actor receives event: overlaps or collides with actor of type
change attribute - count to count +1.
There is another script that moves him from position to position. He is being teleported to each position via change attribute on his position x and position y.
Anyone have any ideas or suggestions? Assuming you understood my rambling that is.![:) :)](http://forums.gamesalad.com/plugins/emojiextender/emoji/twitter/smile.png)
So, starting off, I was spawning and destroying "check-er" actors in all of the possible places where the randomly spawned actors could be, and had a rule that stated: if you overlap of collide with one of these guys, change attribute - count +1. This way I could count up how many of each type were in the scene at specified times.
I knew that spawning and destroying actors was going to be bad for performance, but I did it just to see if that type of behavior worked. And it did. It worked great. Of course my performance sucked, but I got the desired results.
So I decided to optimize it by getting rid of the spawning behavior and instead, just moving the the "check-er" actor from position to position. I figured I would get the same result. I did not. It seems that the "overlaps or collides with" rule is a one shot rule. As soon as my "check-er" hits a type of actor he is supposed to count, he counts up +1 (like he is supposed to do), but when he hits a second one, he does nothing, and the count stays at 1 forever.
Is there anyway to set these rules to NOT be one-shots? As in, EVERY TIME he hits a new actor of the same type, he counts +1.
Here is an example of my script:
rule - actor receives event: overlaps or collides with actor of type
change attribute - count to count +1.
There is another script that moves him from position to position. He is being teleported to each position via change attribute on his position x and position y.
Anyone have any ideas or suggestions? Assuming you understood my rambling that is.
![:) :)](http://forums.gamesalad.com/plugins/emojiextender/emoji/twitter/smile.png)
Comments
Just create something like this:
Create an integer game attribute for every kind of actor that you want to check.
Example:
actor_of_type_one
actor_of_type_two
Than, every time a new actor of type one is spawned, increases actor_of_type_one attribute by +1. Every time one actor of type actor_of_type_one is destroyed, decreases actor_of_type_one by -1.
Do the same think for actor_of_type_two and so on.
____
To use the model you mentionated, try to put the "change attribute - count to count +1" inside a timer, like this:
every(0.1 second){
if(overlaps or collide with actor of type){
change attribute - count to count +1;
}
}
But, this would possible be a FPS killer, if you have too many actors.
This is why I was doing what I was doing. Also, I tried wrapping it in a timer like you suggested, and that didn't seem to work (its unpredictable in its outcome. messes with the the count).