Question by
QuantumGuardian · Jul 25, 2018 at 05:05 PM ·
animationgameobjectunity 2d
(Unity 2D) how can I make an animation play at the local position of the player?
Exactly what the title asks. My player, instead of playing his death animation on the spot, first snaps to origin then plays it. The death animation is a regular legacy animation using the animation component, because animator was a tad too confusing. The animation is triggered when the player collides into another object. Here's my animation code.
```
//Checks whether the object has collided with a rock
if (collision.gameObject.name == "TopRock1" || collision.gameObject.name == "BottomRock1")
{
Animation anim = GetComponent<Animation> ();
anim.Play ("playerCollision");
if (anim.IsPlaying ("playerCollision") == false)
{
Destroy(gameObject);
}
}
}
```
Comment
Your answer
Follow this Question
Related Questions
anyone here to help me with adobe animate 0 Answers
Making a gameobject follow a player closely 1 Answer
How to get a drawn line to snap into a shape? 0 Answers
Child to parent behave weird 0 Answers