Hello!
I am trying to do a game like Stick War 2/ Age War 2 but I have lots of problems with collisions.
Can someone show me a good way to make collisions work well. Now I got a collisions but I got problems. When there is more than one enemy/player in the same spot and gets hit. All of them gets hit.
Example:
2 archer in the same spot. 4 shots collision with them and both die.
Here is the capx.
dl.dropboxusercontent.com/u/7290053/CaveLab/Defense/Defense.capx
I also will be happy if you want give me some advice of how I am coding it.
Thanks in advice.
Peret
To reproduce the anomaly on the collisions.
Let the CPU spawn a few "archers"(3 is okey). Then spawn one of your archers with the icon on the bottom.
And look how the top 3 CPU "archers" will die with only 4 shots. This not should happen.
Develop games in your browser. Powerful, performant & highly capable.
A simple trick is to set the bullet to be invisible on the collision, and also add a check for visibility to the 'On collision' check. Since only the first target checked will have the bullet still visible, only one is eliminated.
SingleCollisionTest_r132.capx
blackhornet Thanks for your time. I tested this but it doesn't work because my enemies have an instance variable of Health, not only one hit.
I think my problem is that when a "shot" hits a "human". I don't know how to do it that only applies this in the "human-Health" that has collisioned not all.
Try 'For each' statement. It a bit resource consuming and tricky though.
The same logic applies for health:
SingleCollisionTest_withHealth_r132.capx
'For each' won't help in this case as 'On collision' is called for each collision already - only one target is picked at a time. You have to do something to have the subsequent calls blocked.
— I can't test it out until monday. It seems it can work on my game. On monday I will tell something about it.
Thank you again
MagicTofu Thanks for your time.
blackhornet I just tested and it's working! :) Thank you very much.