How do I Make my player bounce off from my cactus object?

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.

You can easily do this
go to the physics property and add a new physics material then choose the bounciness option in it and you can now adjust higher or lower bounciness effect

enter what number of bouncy you want
test it and play with it a little till u get your desired bounciness

Hi

Thanks, but as I said my cactus object already has the physics material added with values bounciness 1 and friction 0. The problem is that the velocity of player that collides the cactus makes the player just oscillate e with the cactus. So to fix this i was trying to add some back force to player when the player triggers the cactus in colliding situation:

void OnTriggerEnter2D(Collider2D other)
{
Rigidbody2D rb = other.GetComponent(); rb.velocity = new Vector2(0, 0); rb.AddForce(Vector2.left * 10000,ForceMode2D.Impulse);
}

I tried to add the ForceMode2D.Impulse to physics, but somehow this removes the colliding effect and the player character just walks trough the cactus. I am pretty new to Unity engine, so I am not sure even if asking the correct questions.