Rigidbody bouncing on a gameobject indefinitely
Hello,
I am developing a unity 2D game and following is the issue I am currently facing. I have a platform gameobject which can be either static or moving (vertically or horizontally). When the platform moves vertically downward, any rigidbody placed on the said platform starts bouncing indefinitely. My platform is not a rigidbody, it only has a collider.
What might be the problem and the best way to fix it? Thank you.
Answer by Laktoosi · Jul 18, 2018 at 11:13 AM
You could make the rigidbody a child object of the platform on collision. for example:
void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.tag == ("Player"))
{
collision.transform.parent = this.transform;
}
}
void OnCollisionExit2D(Collision2D collision)
{
if (collision.gameObject.tag == ("Player"))
{
collision.transform.parent = null;
}
}
Sorry bit of a correction here.
-$$anonymous$$ake an empty game object with a collider on top and with your platform script attached
-make your actual platform into its child
-parent the rigidbody object to the empty gameobject on collision.
Your answer
Follow this Question
Related Questions
Setting Continuous Collision Detection is breaking bouncy 2D physics 0 Answers
Sumo Physics Bounce Question 0 Answers
physic material bounciness help 0 Answers
[UNSOLVED] Bouncing ray cast 0 Answers
Rigidbody uncontrollable bouncing on uneven terrain 0 Answers