I have a pickup system in unity2D. When I do a collision with the object I collect it and it disappears. When you collide with it, it then plays an animation and I only want that animation to play for a second. HOW?
Use a coroutine and stop the animation playback manually.
void OnCollisionEnter2D(Collision2D collision)
{
Invoke(nameof(stopAnimation), 1.0f);
}
void stopAnimation()
{
GetComponent<Animation>().Stop();
}