- Home /
Collision Detection on Rigidbody with Interpolation and Rigidbody with Extrapolation is different
Hi, I am using the following approach to get the player grounded:
Grounding:
void OnCollisionEnter2D(Collision2D col)
{
if (!Grounded && col.enabled) // get grounded only if collision is enabled
Grounded = true;
}
Ungrounding:
float Radius = 1.4f;
void FixedUpdate() {
Collider2D[] cols = Physics2D.OverlapCircleAll(transform.position, Radius, GroundLayer);
if (Grounded && cols.Length == 0)
Grounded = false;
}
This works very well if its Rigidbody interpolation is set to "Extrapolate", but does not always work if it's set to "Interpolate" (it does work most of the time). I've tried both Continuous and Discrete collision detection.
I can not use the OverlapCircleAll() method for grounding because I need to get grounded only if the collision is enabled (I have some platforms and don't want to get grounded when coming from the bottom).
Any ideas on how to make it work? Thanks!
Your answer
Follow this Question
Related Questions
How do I fix jitter? 1 Answer
Updating at frameRate some fixedUpdated gameObject 1 Answer
Setting a delay before dashing. 1 Answer
Get Interpolated rigidbody velocity 1 Answer
Player Is able to rotate through walls. 2 Answers