Count collisions
polimerjones
Member Posts: 50
I feel like I am asking too many questions. I appreciate the help people provide and just know I don't just ask. I attempt on my own and ask if I can't figure it out.
I want to find a way to count collisions of a certain actor with its self. Its kinda hard to explain.
Lets see...
If there is gravity and actor 1 is on the ground and another actor 1 lands on top of it i want it to know that is is colliding with one other actor 1. (this i can do)
what i can't seem to get is if a third actor 1 lands on the other two, to get them to know that three are colliding.
what i tried was
"if colliding with actor1 change attribute to attribute+1
else change attribute to 1"
but this only works for two colliding not more than that.
also i would not only like to count to three. i would need this to be able to count as high as possible.
thanks again!
I want to find a way to count collisions of a certain actor with its self. Its kinda hard to explain.
Lets see...
If there is gravity and actor 1 is on the ground and another actor 1 lands on top of it i want it to know that is is colliding with one other actor 1. (this i can do)
what i can't seem to get is if a third actor 1 lands on the other two, to get them to know that three are colliding.
what i tried was
"if colliding with actor1 change attribute to attribute+1
else change attribute to 1"
but this only works for two colliding not more than that.
also i would not only like to count to three. i would need this to be able to count as high as possible.
thanks again!
Comments
Create a self.integer.attribute called active on your actor
Go to your actor
Create a new rule:
If actor overlaps/collides with actor
change attribute self.active = 1
Create a new rule
If actor overlaps/collides with actor and self.active = 1
change attribute game.touch = game.touch +1
Otherwise
game.touch -1
This will make sure it only counts the actors touching and it will only deduct actor after the initial touch.
made this game awhile back with similar features
The second idea is close. I did everything you suggested but also added a display text so i could see the current value and it doesnt work. because the actor1 is spawned, every time its spawned it goes -1 because of that else in the code.
I tried taking that else out and it works but it doesnt just calculate that pile. all actor1's say the same thing i need each pile of actor1's to know how many in the pile.
How about this. Let's reverse the process by elimination so say you set up rules that know when it is colliding with every other type of actor so if it collides with an actor and it can't identify it then you will know it's of the same class. I hope I explained that well enough for you to get the idea.
Give us a bit more info about what you're trying to acomplish and maybe we can direct you to another way to get the mechanics you want.
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
4 actors in a row or touching cause them to destroy...
that kind of thing
Why not take two seconds and try what you suggested on a blank template. You will see it doesn't work.
I was just fiddling with an idea for another game to start after my current one I'm working on. So its not a big deal. GS isn't known for its wide range of abilities.