Counting Collisions when its already touching one of the actors?

TheAJTurnerTheAJTurner Member, PRO Posts: 18

Hi,

Im having a problem with collisions and health. Currently in my game I have a character actor and I have another actor, the rock, that hits the character to decrease its health. The character has a self.health integer attribute set at 10, and I currently have it set as "when actor collides with the rock actor, change attribute 'self.health' to 'self.health-1' ." I dont want the rock actor to destroy after it hits the character. The problem is if the character is touching one rock when it gets hit by another, the health will not go down because it is already touching one. I want it to go down every time it touches a rock. I cant seem to figure this one out...

Comments

  • SocksSocks London, UK.Member Posts: 12,822
    edited May 2016

    Make a game attribute, call it H.

    Rule for the rock:
    When collides with 'character'.
    --change H to H-1

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    It sounds like the problem is that you have a collision rule that has already been triggered and you're wanting it to trigger again. Unfortunately, rules in GameSalad only trigger when their state changes from false to true. So a collision state of TRUE won't allow the rule to trigger another time until the state has been FALSE first.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    If you have multiple instances of the rock in the scene, move the collision rule to the rock actor instead of the character actor.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • SocksSocks London, UK.Member Posts: 12,822

    @tatiang said:
    If you have multiple instances of the rock in the scene, move the collision rule to the rock actor instead of the character actor.

    It's almost as if you read my post :smiley:

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    @Socks Oops. I read it so quickly I didn't notice you had suggested putting that in the rock actor. My bad!

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • TheAJTurnerTheAJTurner Member, PRO Posts: 18

    @Socks @tatiang Thats my problem. I dont think I explained well. I cant use the game attribute because I want to have multiple characters at one time and multiple rocks. And the number of characters and rocks will vary so I dont believe its possible to create a game attribute for each character.

  • SocksSocks London, UK.Member Posts: 12,822
    edited May 2016

    @TheAJTurner said:
    I cant use the game attribute because I want to have multiple characters at one time and multiple rocks.

    Neither of these things prevents you from using game attributes from what I can see ?

    @TheAJTurner said:
    And the number of characters and rocks will vary so I dont believe its possible to create a game attribute for each character.

    Can you expand on this reasoning, what is it about having more than one actor that prevents the use of game attributes, I'm not sure I understand ?

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    @TheAJTurner said:
    @Socks @tatiang Thats my problem. I dont think I explained well. I cant use the game attribute because I want to have multiple characters at one time and multiple rocks. And the number of characters and rocks will vary so I dont believe its possible to create a game attribute for each character.

    Best method would be to have multiple rock actors and rotate between them as they spawn this will limit the possibility of having the same type colliding at the same time.

Sign In or Register to comment.