Fire Knockback

I can imagine this:
21006-knockback.png

I just cannot code it in C#. I think the script should be on fire prefab and it should detect the charactercontroller collision and get the point firstly. Then send charactercontroller by some amount in the opposite direction with gravity so it stops somewhere. (Oh and it should be collision point(x,charactercollider’s bottom.y,z) if collision is a line. I don’t know how it would detect the collision point in ths situation honestly.)

Am I on the right track? Is the script should be attached to fire or character? How to create the direction and move charactercontroller in that way?

Sorry, I’m a beginner but this will help me understand a lot of things. Can anyone help me out?

+1 for detailed question explanation, instead of “plz help need script”.

Anyway, you are on right track. I suggest checking the collison only on player, because if you will have 5 fires, there will be 5 collision checks each frame.

When player collides or triggers, get direction vector from fire to player(you know fire GO from collision), then call some method which apply force and to player in that vector* strength from fire, and create some method to remove heath.

public float health = 100f;

void RemoveHealth(){
    health -= 5f;
}

//When you want to remove health, just call the method
RemoveHealth();

Direction: http://docs.unity3d.com/Documentation/Manual/DirectionDistanceFromOneObjectToAnother.html

Force: Unity - Scripting API: Rigidbody.AddForce

have the collision attached to the player.
and try

void OnCollisionEnter(Collider c)
if(c.gameObject == “Fire”)
{
Health-= fireDamage;
this.rigidbody.addForce(force applied in knockback as Vector3, ForceMode that you are using)
}

check this out to determine what force mode you want to use.

Rigidbody rb;
void Start ()
{
rb = GetComponent();
}
void TakeKnockback(float amount, GameObject hitter)
{
rb.AddForce((transform.position - hitter.transform.position) * 100 * amount);
}
Call TakeKnockback on what is getting hit, use hitter as the object who hit.