Animating a tree with last hit?Solved
Hi!
So i'm trying to make a tree animate and make sounds the same way it does when you last hit it (but without hitting it).

I tried `<Entity>.Kill()` but that just removes the tree instantly.

Any help is greatly appreciated.
In response to Artful ():
Hi!
So i'm trying to make a tree animate and make sounds the same way it does when you last hit...

You mean, to make it fall?

This is how I used to make bradley crash trees

                    var fakeInfo = new HitInfo();
                    fakeInfo.PointStart = APC.transform.position - APC.myRigidBody.velocity * 0.5f;
                    fakeInfo.PointEnd = res.transform.position;
                    tree.OnKilled(fakeInfo);
In response to Artful ():
Hi!
So i'm trying to make a tree animate and make sounds the same way it does when you last hit...
Try 
entity.Hurt(1000f);​
In response to Orange ():
Try 
entity.Hurt(1000f);​
Won't really make it fall in the right direction (if will make fall at all, which I doubt)

Converting the tree to BaseCombatEntity and using hurt doesn't do anything :(

Using ILSpy i found "TreeEntity" and it implements this onkilled method 

Not sure how to implement this though...

public override void OnKilled(HitInfo info)
{
    if (isKilled)
    {
        return;
    }
    isKilled = true;
    CleanupMarker();
    if (fallOnKilled)
    {
        Collider collider = GetCollider();
        if ((bool)collider)
        {
            collider.enabled = false;
        }
        ClientRPC(null, "TreeFall", info.attackNormal);
        Invoke(DelayedKill, fallDuration + 1f);
    }
    else
    {
        DelayedKill();
    }
}
In response to 2CHEVSKII ():
You mean, to make it fall?This is how I used to make bradley crash trees var fa...
Ahh yeah this is exactly what i wanted. Only difference is instead of APC it's a player, and players don't have a "myRigidBody".
In response to Artful ():
Ahh yeah this is exactly what i wanted. Only difference is instead of APC it's a player, and players...

You just need a vector3, which will determine direction of fall. You can just assign player pos as PointStart and tree pos as PointEnd.

I'd do something like

            var info = new HitInfo();
            info.PointStart = player.transform.position - (tree.transform.position - player.transform.position) * 2;
            info.PointEnd = tree.transform.position;
In response to 2CHEVSKII ():
You just need a vector3, which will determine direction of fall. You can just assign player pos as P...
Ahh you're amazing!

Thanks for the help.
Locked automatically