collisions and tags and sequential damage..?? -\-
TouchiMedia
Member Posts: 154
I'll begin with that I did try to search for this and came up with a couple topics but there was never a clear answer that worked for me.
I have collisions between two actors. We'll say, Actor 1 and Actor 2.. Actor1 is spawned when mouse is released (think of Actor 1 as projectile). Actor 2 is Brick.
I want to have progression damage.. so I have a rule(1) setup on Brick - when collides with Projectile - change animation to 'damaged brick' .. works all fine and dandy.
Then I have a second rule (I tried placing this before and after rule1) - when collides with Actor 1 -AND- image is damaged brick - destory....
Problem is the Projectile lays up against the brick sometimes, therefore will hit it, go from damaged then destroyed within a second. I only want the damaged brick to be destroyed when a second/different projectile hits (same 'actor' different instance' of projectile).
My initial thought was to change tag of Projectile when collides with Brick to 'blank' (something different from original tag) and use the collision with tag for rule2 on Brick.. but from what I understand, we can't change tags during runtime..And haven't had luck with this when I tried.
I have also tried using Game/Global Attributes but still can't figure out a way because the Projectiles are being spawned so makes things a little bit more difficult.
I know there must be a workaround but my brain is frozen at the moment! Is there a way to do this with Tables? This is one area that I'm not too familar with ..
I have collisions between two actors. We'll say, Actor 1 and Actor 2.. Actor1 is spawned when mouse is released (think of Actor 1 as projectile). Actor 2 is Brick.
I want to have progression damage.. so I have a rule(1) setup on Brick - when collides with Projectile - change animation to 'damaged brick' .. works all fine and dandy.
Then I have a second rule (I tried placing this before and after rule1) - when collides with Actor 1 -AND- image is damaged brick - destory....
Problem is the Projectile lays up against the brick sometimes, therefore will hit it, go from damaged then destroyed within a second. I only want the damaged brick to be destroyed when a second/different projectile hits (same 'actor' different instance' of projectile).
My initial thought was to change tag of Projectile when collides with Brick to 'blank' (something different from original tag) and use the collision with tag for rule2 on Brick.. but from what I understand, we can't change tags during runtime..And haven't had luck with this when I tried.
I have also tried using Game/Global Attributes but still can't figure out a way because the Projectiles are being spawned so makes things a little bit more difficult.
I know there must be a workaround but my brain is frozen at the moment! Is there a way to do this with Tables? This is one area that I'm not too familar with ..
Comments
When actor collides with [bullet]
Animate/change image
When actor collides with [bullet] AND image is damaged brick
Destroy actor
The way to prevent this is to build in a delay:
When actor collides with [bullet] AND attribute self.damaged [boolean] is false
Animate/change image
Timer after 0.1 seconds [run to completion checked]
Change attribute self.damaged to true
When actor collides with [bullet] AND attribute self.damaged is true
Destroy actor
*You might have to adjust the timer to make it longer, but 0.1 should work if your actor is relatively small in size and the projectile is moving relatively quickly and/or gets destroyed upon impact.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
I have actually tried the delay method... Maybe I had it correct and other parts not, it was 3am and was seeing double
I should state that I had a game attribute called 'hardhit' which turns true if the velocity of the projectile when it collides with brick is over a certain amount.
So initially I had something like this (I'm going off memory as I'm not at gamesalad comp.)
---------------------------
When actor(brick) collides with [bullet] AND attribute game.hardhit [boolean] is true
***Animate/change image
***Timer after 0.2 seconds [run to completion checked]
******Change attribute game.hardhit to false
******Change attribute self.damaged to true
----------------------------
So I had to change the 'hardhit' attribute to false after 0.2 seconds because sometimes the projectile would hit multiple bricks/actors - but if I didn't delay , it'd only change the first brick hit to 'damaged' instead of multiple.. Then I put in Rule2=
----------------------------
When actor collides with [bullet] AND attribute self.damaged [boolean] is true
***Destroy
----------------------------
Not sure why I was having issues, nor do I know if I had the 'run to completion checked' -- I'll try to report later in the evening when I'm back at my project.
I do appreciate the help/input.
When self.hit = 1 trigger your animation and
self.hit = 2 destroy the actor
I think my issue was trying to get the projectile to destroy the damaged brick even when not going at hardhit velocity but also only from a different projectile that did the damage initially (confusing I know)
Appreciate the insight both of you
@slowcut Either should work as long as there is a delay. Without a delay, an index/integer "state" will still immediately convert to the final value since the rules are true instantly.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
I think originally I had the 'game.hardhit' attribute in the time delay loop, but not the 'self.damaged' attribute.
In a few hours I can test it and report back specifics with the delay method.
Ahh the pains and glories of coding
Thanks again!
Also, I didn't have the 'run to complete' checked, which caused some inconsistencies. Overall acting much better, appreciate all the help. Sleep deprivation not good with coding