Grenade Force Applied To Character

I have a grenade that works but it only has a force towards objects. Can you tell me how to put the force towards myself without inflicting damage? Its going to be like a shockwave grenade. The Script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Grenade : MonoBehaviour
{

    public float delay = 3f;
    public float radius = 5f;
    public float force = 700f;

    public GameObject explosionEffect;

    float countdown;
    bool hasExploded = false;

    // Start is called before the first frame update
    void Start()
    {
        countdown = delay;
    }

    // Update is called once per frame
    void Update()
    {
        countdown -= Time.deltaTime;
        if (countdown <= 0f && !hasExploded)
        {
            Explode();
            hasExploded = true;
        }
    }

    void Explode()
    {
        Instantiate(explosionEffect, transform.position, transform.rotation);

        Collider[] colliders = Physics.OverlapSphere(transform.position, radius);

        foreach (Collider nearbyObject in colliders)
        {
            Rigidbody rb = nearbyObject.GetComponent<Rigidbody>();
            if (rb != null)
            {
                rb.AddExplosionForce(force, transform.position, radius);
            }

            // damage
        }

        Destroy(gameObject);
    }
}

This is Brackeys code not mine

The code above is using this method:

That handles all the direction stuff automagically, including the attenuation as you reach the edge of the radius.

Instead you probably want to subtract the grenade position from the player’s position to come up with a vector for the force, then use some kind of curve to decide how it falls off over distance, something like:

Vector3 VectorToPlayer = (PlayerPosition - GrenadePosition);

float distance = VectorToPlayer.magnitude;

TODO: use distance to evaluate how hard to push (I recommend an AnimationCurve property for easy editing)

TODO: use VectorToPlayer.normalized multiplied by the above push calculation and do an AddForce() on the player’s Rigidbody.