So I have a sphere for the player, and whenever the player is damaged by an object it should knock the ball into the opposite direction, so I am using AddExplosionForce to do the effect, but sometimes it knocks the player back and sometimes it doesn't do anything. Is there something I can do to fix my code (below) or an alternative to doing this effect? Thank you!
private void OnTriggerEnter(Collider other){
if(other.tag == "Pickup")
{
if(other.GetComponent<pickupScript>().ReturnSize() >= score)
{
score--;
//explodeforce in oposite direction
GetComponent<Rigidbody>().AddExplosionForce(500.0f, other.transform.position, .501f, .5f, ForceMode.Impulse);
//add effects
}
}