- Home /
Question by
liero116 · Nov 24, 2015 at 09:48 PM ·
arraycollision detection
Multiple collision array
So I have a set of characters who have sphere colliders parented to various joints to detect attack collisions. For example, one attached to the head, the arms, legs, etc. Each collision is managed and stored in an array.
The issue I am currently having is when an attack hits a character, the attack is triggering once for each separate collision on the character. I want the attack to detect only the first collision it touches on the player and ignore the rest.
How can I do this?
Comment
Answer by Mich_9 · Nov 25, 2015 at 03:10 PM
You can make every body part check for a "hit" flag, if is set then the other colliders ignores that hit.
//adjust this code to your preferred language
private hit = false;
OnCollisionEnter(){
if(!hit) {
hit = true;
//hit logic goes here
}
}
Your answer