oncollisionexit not working
I made a code that causes the platform the player is standing on to fall after being left. void
public Rigidbody rb;
public GameObject player;
void Start () {
rb = GetComponent<Rigidbody> ();
}
void OnCollisionExit(Collision other){
if (other.gameObject.CompareTag ("player")){
rb.useGravity = true;
}
}
but when the player stands on a platform, it immediately falls without the player having left the platform. I there a fix to this?
Answer by This-is-Cole · Jan 19, 2017 at 04:45 PM
Hi Marshel! One possible solution is to use a box collider as a trigger and use OnTriggerExit instead of OnCollisionExit. You can make the box slightly higher so that you'll be sure the player is jumping away before the exit is called.
When I do this, the player just falls through the ground instantly. Does making the player's collider a trigger change the collider in some way?
Your answer
![](https://koobas.hobune.stream/wayback/20220612105146im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Copy collision object position (Or just "fly" a little bit) 0 Answers
Rigidbody - How to make it jump and fall down fast ? Help needed. 1 Answer
Sphere bouncing back on edges of aligned objects 0 Answers
Restrict held object movement 0 Answers
Position and collider seem to incorrectly shift when moving object 0 Answers