Mesh->GetAnimInstance() is always NULL on 4.15 no matter what

I would like to modify a few on my mesh as camera pitch changes during the game. So, after googling around I came across this thread How can I rotate Bones Purely In C++? - Character & Animation - Unreal Engine Forums and decided to sub-class AnimInstance and FAnimInstanceProxy. Here is the code for my sub-classed AnimInstance:

Header file: /** * @author Mohammad S. Babaei <info@babaei.net> * * @section LICENSE - Pastebin.com
Source file: /*** @author Mohammad S. Babaei <info@babaei.net>** @section LICENSE* C - Pastebin.com

If I overrode virtual FAnimInstanceProxy* CreateAnimInstanceProxy() override; the AnimBlueprints stops working inside the editor so I leaved that out for the moment.

Now, the main problem is when I try to get the AnimInstance at the runtime, Mesh->GetAnimInstance() always return NULL. I tried every possible solution on this thread How to set animation blueprint in c++ - Character & Animation - Unreal Engine Forums without any luck. Inside the constructor I’m able to find the sub-classed AnimBlueprint (from my UAnimInstance). But setting it through SetAnimInstanceClass won’t work and Mesh->GetAnimInstance() is NULL. It looks like AnimBlueprintGeneratedClass has been deprecated for a while, too. So, setting that does not work either. Furthermore, I tried SetAnimInstanceClass inside constructor and BeginPlay with the same results.

I appreciate it your help.

Are you set SkeletalmeshComponent’s AnimationMode to Use Animation Blueprint?

Yes I did but it’s the same.

The only thing that worked for me was setting Animation Mode and Anim Class through the editor inside the sub-classed character blueprint. It seems C++ does not work anymore or something in the API changed or there must be another way to do that in the new versions of UE4.