- Home /
How to play the same animation for many objects(taken from the same prefab) but starting from different frames
Well , i made a game that whenever you shoot a duck ... it should play the death animation and fall to the ground , and that's fine. but when i shoot it ... the death animation plays for all ducks (they do not fall) , so how could i make for example that duck that has been shot ,play the death animation and the other ducks stay playing the flying animation?
I'm using an animation controller with one variable for the animation .
public class DuckDeath : MonoBehaviour { static Animator D_anim; public Rigidbody DuckRB; public float DisappearingTime = 3;
void Start () {
D_anim = GetComponent<Animator>();
}
void OnCollisionEnter (Collision COL) // when hit by a bullet
{
if (COL.collider.name == "TERRAIN" || COL.collider.name == "DeathPlane") // forget that
{
D_anim.SetFloat ("DuckState", 1.25f);
StartCoroutine (DisappearingDelay(DisappearingTime)); // destroys duck after x seconds
}
else
{
DuckRB.useGravity = true;
D_anim.SetFloat ("DuckState", 0.25f); //death animation play
}
Debug.Log ("DUCK HAS BEEN HIT");
}
Answer by jfonz001 · Jan 09, 2018 at 02:47 AM
Alright so I think 90% of my problem was because my player's attack animations did not loop while the armor's animations did. Check if your animations are looping, future folks
Your answer
Follow this Question
Related Questions
Animation Control 0 Answers
Animations don't work with humanoid avatars 0 Answers
Character animation position 1 Answer
Mirroring animation clip without mirroring root motion node? 0 Answers