Counting Collisions when its already touching one of the actors?
TheAJTurner
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
Make a game attribute, call it H.
Rule for the rock:
When collides with 'character'.
--change H to H-1
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
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
It's almost as if you read my post
@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
@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.
Neither of these things prevents you from using game attributes from what I can see ?
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 ?
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.
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS