[Solved] How to Bounce Off 2D?

I have visited many tutorials and seen many resolved questions, but none answer my question, I want the player to bounce off an explosion in the opposite direction it collided with it:

Graphic Representation

The explosion is not always there, it happens when the player touches that exploding apparatus, then the exploding apparatus spawns an explosion prefab, that works perfecltly fine, but the explosion (as its bigger than the exploding apparatus) only throws the player out of its collider’s range, instead of far far away as Id like it, the player can hit the exploding apparatus from any of the 360 degrees 2D games provide, so coding 360 lines for every possibility its the last thing I want to do, I am sure there is an easier way to achieve this.

Thanks for your help

Have you tried using a physics material with a high bounce value?

You might also try to do a OnCollisionEnter2D and use the Collision2D’s relativeVelocity to send the player away from the explosion. Something like this:

    void OnCollisionEnter2D(Collision2D other)
    {
        GetComponent<Rigidbody2D>().AddForce(other.relativeVelocity.normalized * -200);
    }

Yeah, Ive tried a high bounciness material, but only works when you run into the explosion, but as its a prefrab spawned when you already collided with the exploding apparatus, you already lost all velocity, making the bounce 0.

Let me see how that one works

Welp, thanx a lot, my explosions now work :smile: