- Home /
rigidbody2D.addforce in collider
Hello, I'm trying to do a small project in 2d but am having a little problem with a script
void OnCollisionEnter2D(Collision2D info) { if (info.gameObject.tag == "Player") {
float height= info.contacts[0].point.y - weakness.position.y;
if(height>0)
{
Dies();
info.rigidbody.AddForce(new Vector2(0,300),ForceMode2D.Impulse);
}
}
The problem is that my player has a rigidbody2D but
info.rigidbody.AddForce (new Vector2 (0,300), ForceMode2D.Impulse);
is not possible put it.
basically my player should bounce after jumping over an enemy (Super Mario Style)
Do you have any idea to solve it?
Comment
Best Answer
Answer by muzzammal.sultan · Jan 29, 2015 at 01:28 PM
just rigidbody.AddForce (new Vector2 (0,300), ForceMode2D.Impulse); no need of info.rigidbody