# How do I freeze animation montage at end of animation cycle in code?

**URL:** <https://forums.unrealengine.com/t/how-do-i-freeze-animation-montage-at-end-of-animation-cycle-in-code/299535>\
**Category:** Character & Animation\
**Tags:** unreal-engine, CPP, question\
**Created:** [November 21, 2014, 11:58am UTC](https://forums.unrealengine.com/t/how-do-i-freeze-animation-montage-at-end-of-animation-cycle-in-code/299535 "2014-11-21T11:58:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jesper\_Bergstrom](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Jesper\_Bergstrom](https://forums.unrealengine.com/u/Jesper_Bergstrom)\
**Post date:** [November 21, 2014, 11:58am UTC](https://forums.unrealengine.com/t/how-do-i-freeze-animation-montage-at-end-of-animation-cycle-in-code/299535/1 "2014-11-21T11:58:39Z")

</div>

Hi.

I’m playing my AnimMontage like this:

```
void AActivateItem::PlayAnimation()
{
    // try and play a door open animation if specified
    if (OpenAnimation != NULL)
    {
        // Get the animation object for the skeletal mesh
        UAnimInstance* AnimInstance = Mesh->GetAnimInstance();
        if (AnimInstance != NULL)
        {
            if (!AnimInstance->Montage_IsActive(OpenAnimation))
            {
                AnimInstance->Montage_Play(OpenAnimation, 0.2f);
            }
        }
    }
}

```

When I play the animation, the anim montage plays from start to finish, and then at the end of animation cycle it goes back to the starting position. How do I stop the animation montage at end of cycle, in CODE?

I’m trying to get the door to stay open when the animation montage is finished.

---

<div class="post-metadata">

**Author:** ![Jesper\_Bergstrom](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Jesper\_Bergstrom](https://forums.unrealengine.com/u/Jesper_Bergstrom)\
**Post date:** [November 21, 2014, 12:59pm UTC](https://forums.unrealengine.com/t/how-do-i-freeze-animation-montage-at-end-of-animation-cycle-in-code/299535/2 "2014-11-21T12:59:32Z")

</div>

I found the answer at another question. Still, I tried to google the answer for hours, and the question didn’t come up. So I’ll just answer to my own question:

When you want to FREEZE an animation montage via C++ code, set GlobalAnimRateScale to 0.0:

```
SkeletalMeshComponent->GlobalAnimRateScale = 0.0;

```

To control at which position you want to freeze the animation (I used the following code):

```
float f = AnimInstance->Montage_GetPosition(OpenAnimation);
if (f > 0.75)
{
    SkeletalMeshComponent->GlobalAnimRateScale = 0.0;
}

```

---

<div class="post-metadata">

**Author:** ![anon26705860](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anon26705860](https://forums.unrealengine.com/u/anon26705860)\
**Post date:** [November 21, 2014, 7:53pm UTC](https://forums.unrealengine.com/t/how-do-i-freeze-animation-montage-at-end-of-animation-cycle-in-code/299535/3 "2014-11-21T19:53:36Z")

</div>

I think a cleaner method would be to set bNoSkeletonUpdate to true or bPauseAnims to true on the skeletalMeshComponent.

---

<div class="post-metadata">

**Author:** ![Jesper\_Bergstrom](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Jesper\_Bergstrom](https://forums.unrealengine.com/u/Jesper_Bergstrom)\
**Post date:** [November 25, 2014, 1:54pm UTC](https://forums.unrealengine.com/t/how-do-i-freeze-animation-montage-at-end-of-animation-cycle-in-code/299535/4 "2014-11-25T13:54:23Z")

</div>

This works fine aswell!
