# UAnimInstance is a nullptr

**URL:** <https://forums.unrealengine.com/t/uaniminstance-is-a-nullptr/600777>\
**Category:** C++\
**Tags:** unreal-engine, UE5-0, CPP\
**Created:** [July 9, 2022, 4:52am UTC](https://forums.unrealengine.com/t/uaniminstance-is-a-nullptr/600777 "2022-07-09T04:52:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![peterw1505](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/peterw1505/32/88710_2.png) [@peterw1505](https://forums.unrealengine.com/u/peterw1505)\
**Post date:** [July 9, 2022, 4:52am UTC](https://forums.unrealengine.com/t/uaniminstance-is-a-nullptr/600777/1 "2022-07-09T04:52:15Z")

</div>

Dear experts,

I try to call a Montage from C++ and the code looks like this. However, the UE\_LOG in red never gets called:

 ![cpp_callMontage](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/f/3/7f3f57b7f62cde6683bb01939d62a26e44fc7ff5.png)

My AnimInstance I think is a nullptr. But why?  
I am setting up the character with “SetMasterPoseComponent” and on the Jacket I set the Animation Blueprint:

 ![char_BP](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/2/a/62a2c6f0646f8b5f064bbc6fe05b536b2dc969ef.png)

How is it that my AnimInstance is null? Any ideas what I have to look for?

Thank you

---

<div class="post-metadata">

**Author:** ![pladux](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/pladux/32/1194519_2.png) [@pladux](https://forums.unrealengine.com/u/pladux)\
**Post date:** [July 10, 2022, 9:26am UTC](https://forums.unrealengine.com/t/uaniminstance-is-a-nullptr/600777/2 "2022-07-10T09:26:16Z")

</div>

Have you verified CombatMontage is actually set? You should really be using a debugger. Makes things a lot (I mean a lot!) easier.

---

<div class="post-metadata">

**Author:** ![peterw1505](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/peterw1505/32/88710_2.png) [@peterw1505](https://forums.unrealengine.com/u/peterw1505)\
**Post date:** [July 10, 2022, 1:04pm UTC](https://forums.unrealengine.com/t/uaniminstance-is-a-nullptr/600777/3 "2022-07-10T13:04:18Z")

</div>

Hello Pladux

yes, even in the debugger I can see that the UAnimInstance I have is null:

 ![debug](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/1/f/41f5e141bdc940f7a499bbeba9d59113ef6b4754.png)

All I am doing in the .h file is this:

```auto
UPROPERTY(EditAnywhere,BlueprintReadWrite,Category="Movement")
	UAnimInstance* AnimInstance;

```

Do I have to set it in the Constructor or BeginPlay() ? I thought it is there automatically.

---

<div class="post-metadata">

**Author:** ![peterw1505](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/peterw1505/32/88710_2.png) [@peterw1505](https://forums.unrealengine.com/u/peterw1505)\
**Post date:** [July 10, 2022, 11:01pm UTC](https://forums.unrealengine.com/t/uaniminstance-is-a-nullptr/600777/4 "2022-07-10T23:01:24Z")

</div>

I realized looking at this: [https://forums.unrealengine.com/t/how-can-i-get-skeletal-mesh-animinstance-and-then-cast-it-using-code/283271](https://forums.unrealengine.com/t/how-can-i-get-skeletal-mesh-animinstance-and-then-cast-it-using-code/283271)

that I have to change some code. I did that and it looks better, AnimInstance does not show a NULL anymore:

 ![changedcode](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/3/f/a3f32d67ef3aaa3ed0031659550f4cdef064ccbe.png)

But still when I test play the game, the montage “AM\_Sword” is not played when I attack. Do I need to anything in the animation blueprint? I only created the montage “AM\_Sword”.

---

<div class="post-metadata">

**Author:** ![peterw1505](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/peterw1505/32/88710_2.png) [@peterw1505](https://forums.unrealengine.com/u/peterw1505)\
**Post date:** [July 10, 2022, 11:17pm UTC](https://forums.unrealengine.com/t/uaniminstance-is-a-nullptr/600777/5 "2022-07-10T23:17:06Z")

</div>

found it, I have to add a “Slot” for the montage within the animation blueprint:

 ![addslot](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/1/8/1185a0b52435caa8f2fd54d0082895a83b61172c.png)
