Count collisions

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!

Comments

  • mi1ezmi1ez Member, PRO Posts: 18
    Try taking out the "otherwise change attribute to 1" part. And also make sure the attribute is set to 0, not 1.
  • WingmanappsWingmanapps Member Posts: 458
    edited July 2013
    Create a game.integer.attribute called touch.
    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

  • polimerjonespolimerjones Member Posts: 50
    Thanks but neither of those work.

    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.
  • polimerjonespolimerjones Member Posts: 50
    Like This

    Image and video hosting by TinyPic
  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    edited July 2013
    I take it you're making a stacking type game with types of objects and the need to be placed in strings?

    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.
  • polimerjonespolimerjones Member Posts: 50
    I think it might be impossible to do what I want, in this fashion. I think I might have to go about it another way.
  • polimerjonespolimerjones Member Posts: 50
    I was thinking of a style of puyo pop.

    4 actors in a row or touching cause them to destroy...

    that kind of thing
  • WingmanappsWingmanapps Member Posts: 458
    Well it worked perfectly in my game. You do know the difference between a global attribute and a self attribute
  • polimerjonespolimerjones Member Posts: 50
    edited July 2013
    Yea. I know the difference.

    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.
Sign In or Register to comment.