enemy bounce back trying to use rigidbody2d

Hello,

i am trying to do something simple, hopefully simple, when player touches enemy, the enemy bounces back, maybe a few feet or inches or whatever back, even if the player is just standing there, the enemy player touches, then the enemy bounces back…

i tried to use:

if(Player_Hit)
        {
            rb.AddForce(transform.forward * 10 * Time.deltaTime);
        }

however this never fires, even though i put a Debug.Log(“TEST”); in there, and i do see the console TEST, so it does work, but the enemy object doesnt move back… any idea or maybe something else i should use?

Why are you multiplying by Time.deltaTime for a single application of a force? That will make the game’s frame rate change the amount of force applied, so a slow computer will see a much bigger force. That will also result in a very small force that may not even move the object. Try setting a much larger force without multiplying by Time.deltaTime and see if it moves at all.

See the example. Also since you just want one impulse, use the ForceMode.Impulse.