Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Object not keeping the scale after playing an animation in Unity

I have an animation that scales an object down when it 'sleeps'

When the object wakes back up again, there is a 'wake' animation that scales the object back up to normal.

When the object sleeps, I also set it's game object as inactive. When it wakes up I set it as active.

The first time that this animation plays, the object stays at the normal scale.

However, When it wakes up after dying, the wake animation plays, but the scale does not stay. The object scales back down immediately after the animation for some reason.

Here is my animator component on the object:

enter image description here

Is there a better way to set something so simple up? Right now I am just saying in my script:

anim.SetTrigger(sleepAnimationTriggerName); 

The object is a prefab, and there are at least 15 of them in the scene at any given time.

I have tried resetting the scale when the object sleeps, by storing the transform.localescale of the object and resetting it in the OnDisable() method. This didn't work.

Any ideas?

like image 985
BenjaFriend Avatar asked Sep 11 '25 17:09

BenjaFriend


1 Answers

Just Uncheck the checkbox Write Defaults in the Idle Animations:

enter image description here

like image 154
Ludovic Feltz Avatar answered Sep 13 '25 06:09

Ludovic Feltz