Hi all,
I am creating an adventure game, and bumbed up to a problem. I am trying to get the player character smoothly bounce of from cactus, when collided. So here are the current attributes:
The cactus has Box Colllider 2D attached with physics materia with bounce set to one and friction 0. The Box collider has the Is Trigger cheked. The Cactus also has an script attached to it containg implementation of : void OnTriggerEnter2D(Collider2D other)
The implementation has next code attached to it:
void OnTriggerEnter2D(Collider2D other)
{
Debug.Log(other.name);
Rigidbody2D rb = other.GetComponent();
rb.velocity = new Vector2(0, 0);
rb.AddForce(Vector2.left * 10000,ForceMode2D.Impulse);
}
Here the Collider2d is the player and I am trying to add force to player bumb back when it hits to cactus object. The problem is that when I add the ForceMode2D.Impulse the player character just walks trough the cactus. If I remove it the player bouneces, but too quickly.
The player objetct has colliders and rigigdbody2d attached. What’s the problem guys? What I am doing wrong to no the Impulse work correctly.