- Home /
Question by
akyu01 · May 05, 2020 at 05:55 AM ·
colliderhit detection
Player Enemy Hit Collider Edges issue
I have a player that when hit the enemy collider it flies backward with a certain velocity. However When hit from above the enemy box collider it works fine, but when hit from enemy box collider sides the X velocity doesn't seem to work although its direction is to the negative side of the enemy.
if (isHitByEnemy) { NumOfHit +=1; isHittingEnemy = true;
Vector2 IntPos = new Vector2 (player.velocity.x,player.velocity.y);
Vector2 EndPos = new Vector2 (12*-facingDirection,10);
player.velocity = Vector2.Lerp(IntPos,EndPos,Time.time);
}
}
Comment
Your answer
Follow this Question
Related Questions
OnCollisonEnter never being called 1 Answer
Need second pair of eyes: rigidbodies with colliders not firing OnCollisionEnter yet again... 1 Answer
Internal collisions 1 Answer
How can i detect hits from enemies inside of a player? 1 Answer
Why do my bullets only destroy themselves sometimes after colliding with the wall? 0 Answers