How to make the player be pushed by a fireball?

Alright, so lets say there's 4 characters and the cam is Top View Down.

the point of the game is to push eachother out by casting a fireball, and that fireball pushes them towards whichever way the fireball is going.

I've tried scripting and using its phisycs but for some reason I can never get it to work as I want it to.

Whats the easiest way to make the fireball push the player towards the position its going.

I"ve tried playing with the rigidbody's masses, etc. Nothing worked as good, they get pushed maybe a little. Also tried addrelativeforce towards the position the fireball was going... Any help will be useful thanks a lot... and also the Y axis will always be at 0.

Basically, i need help with either a script or some adjustments i have to make so the fireball pushes the player/ or something in its way towards where ever its going. (Aiming for my own variable, to push in distance) I've played with it back and forth and not a good system yet,,, any suggestions etc will be appreciated thanks.

In real physics, the player would not be pushed in exactly the same direction as the fireball is traveling. It all depends on the impact angle of the colliding object (fireball). So if you still want to move the player in the same direction as the fireball, you need the add the force manually.

I would suggest that you mark the collider on the fireball as a trigger, and use the OnTriggerEnter function on a script placed on the player. It could look something like this:

c#

void OnTriggerEnter(Collider other)
{
   if (other.gameObject.tag.Equals("fireball"))
   {
      this.rigidbody.AddForce(other.rigidbody.velocity * multiplier);
   }
}

Js

function OnTriggerEnter(other Collider)
{
   if (other.gameObject.tag.Equals("fireball"))
   {
      this.rigidbody.AddForce(other.rigidbody.velocity * multiplier);
   }
}

Make sure that both objects has a rigid body and you move the fireball using the build in physics system (not using transform.posision to move the object)

If you want the player to be pushed relative to the point of impact i would suggest that you use AddExplosionForce. It could look something like this. (remove the isTrigger mark on the fireballs collider)

C#

void OnCollisionEnter(Collision collisionInfo)
{
   if (collisionInfo.gameObject.tag.Equals("fireball"))
   {
      this.rigidbody.AddExplosionForce(explosionForce, collisionInfo.transform.position, explosionRadius);
   }
}

Js

function OnCollisionEnter(collisionInfo Collision)
{
   if (collisionInfo.gameObject.tag.Equals("fireball"))
   {
      Debug.Log("Boom");
      this.rigidbody.AddExplosionForce(explosionForce, collisionInfo.transform.position, explosionRadius);
   }
}