Adding knockback to a 2D game (in C#)

Ok so I’m currently working on a 2D game (Platformer kinda) in my freetime, i dont know a lot about coding or stuff like that but until now I’ve created a player which can move around, using animations, that also has health. I’ve also added some “spikes” that deal damage to the player.

What I’m having trouble with is adding “knockback” to the player when it hits the spikes. I don’t really know how to do it and the ways i have tried don’t seem to work.

I would really like it if anyone could help me create/add this to the game, and preferably as soon as possible.

Thanks in advance!

watch this it helps.

if your using rigidbodies just you

rigidbody.Addforce(new Vector2(“x axis”, “y axis” ))