- Home /
Answer by Atto2O · Aug 01, 2019 at 12:38 PM
If someone need a quickFix, that work for me ( PlayerManager.Instance.gameObject is the player gameObject):
private void OnCollisionEnter(Collision collision)
{
if (collision.gameObject == PlayerManager.Instance.gameObject)
{
GetComponent<Rigidbody>().isKinematic = true;
GetComponent<Rigidbody>().useGravity = false;
GetComponent<Rigidbody>().velocity = Vector3.zero;
GetComponent<Rigidbody>().angularVelocity = Vector3.zero;
}
}
private void OnCollisionExit(Collision collision)
{
if (collision.gameObject == PlayerManager.Instance.gameObject)
{
// switch to 'non-kinematic'
GetComponent<Rigidbody>().isKinematic = false;
GetComponent<Rigidbody>().useGravity = true;
GetComponent<Rigidbody>().velocity = Vector3.zero; // or another initial value
}
}
STILL INTERESTED IN A BETTER SOLUTION
Your answer
![](https://koobas.hobune.stream/wayback/20220612205854im_/https://answers.unity.com/themes/thub/images/avi.jpg)