hello, I have a script that hurts the player when they are hit by an entity, but i want the player to bounce back in the opposite direction of the entity hitting it.

how can i calculate the force vector to bounce back from being hit? I am using the physics engine.

this is what i have so far:

function bounce_back()
{
//point player towards object
vec_set(temp.x, you.x);
vec_sub(my.x, temp.x);
vec_to_angle(my.pan, temp.x);

var back_force;

vec_set(back_force.x, my.pan);
//take the pan and make it negative, multiply
vec_normalize(back_force, -10000000);

phent_addcentralforce(me, back_force.x);
}

tips would be appreciated. thank you