- Home /
Collisions issues of CharaterController with other box colliders
I have a Player with a CharacterCollider & Coins with box colliders. When my player collides with coin, then i m disabling coin in OnControllerCollideHit() with hit.gameObject.active = false (where hit = coin gameObject).
But still i m getting some back force or a kind of jerk when i collide with coin.
How can i remove that jerk or force on player collision with any coin box collider.?
I did a lot of research on Google & some forums, but can't find related to this issue.
Any Code will be appreciated.
Thankx
Answer by roamcel · Jul 03, 2012 at 08:31 AM
Two ways to do this:
1) assign the collider host gameobject to different layers, and then use the "collision matrix" (edit=> project settings=> physics) to setup two different, non colliding layers where you respectively assign the coin prefab and the player prefab.
2) make the coin collider a TRIGGER. Just select the trigger checkbox.
But your solutions will make player not to collided with coin. Then How can i get coin collected count?
$$anonymous$$ost certainly they will collide, but not on a physical level. They will collide at 'trigger' level, so you must use:
void OnTriggerEnter() {
//your code
}
http://docs.unity3d.com/Documentation/ScriptReference/Collider.OnTriggerEnter.html