Player with collider goes through another object's collider upon first collision, works only on second time
my player has a rigidbody with a box collider with collision detection set to continuous dynamic. when i move my player into the wall it goes through the wall for the first time and makes my game extremely slow and then it takes another collision to actually register it.
i have heard that in case of fast moving objects the collisions tend to skip 1but my game is not that super fast and since it makes the game slower i can tell it did collide.
this is the code i am using for collision detection:
void OnTriggerEnter(Collider c){
if (c.transform.tag == "Enemy") {
die ();
PlaySound (1);
flag = 1;
canmove = false;
}
else if (c.gameObject.tag == "gem") {
PlaySound (0);
Destroy (c.gameObject);
}
}
on the first collision it plays the sound which means PlaySound(1);was executed but it doesnt execute die(); for some reason until i collide it again. the role of die method is to save the score and bring the game over UI up.
the walls are set to trigger and are tagged as "Enemy". i tried using OnCollisionEnter as well without triggers but same results.
Your answer
Follow this Question
Related Questions
player going through walls even though it has colliders and rigidbodies 0 Answers
Spawned objects sink through ground, when over 3 clones 0 Answers
Collision not working on colliding object rotation vector3 0 Answers
How can I detect collision between two objects when one can't have a rigidbody applied? 1 Answer
Collisions Detection Functions Not Called, Walking Through Walls 2 Answers