Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Mesh->GetAnimInstance() returns NULL

Dear community,

I have the following problem:

I’ve created a custom UAnimInstance class called UHandAnimInstance

 UCLASS(transient, Blueprintable, hideCategories = AnimInstance, BlueprintType)
 class UHandAnimInstance : public UAnimInstance
     UPROPERTY(EditDefaultsOnly, Category = Phone)
     UAnimMontage* _phoneOn;
     UPROPERTY(EditDefaultsOnly, Category = Phone)
     UAnimMontage* _phoneOff;
     void ShowPhoneLight(bool doShow);

I’ve reparented my animation blueprint called AnimHandBP and set up both montages. So far it works perfectly.

I have my FirstPersonCharacter blueprint derived from my C++ class called ATheForestCharacter This character has a Mesh called HandAnim and there I’ve set up in the editor:

Animation Mode: Use Animation Blueprint

Anim Blueprint Generated Class: AnimHandBP_C

Please note that the mesh itself is created in C++ in a constructor of ATheForestCharacter like this:

 HandAnim = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("HandAnim"));
 HandAnim->AttachParent = FirstPersonCameraComponent;
 HandAnim->RelativeLocation = FVector(29.801f, 17.787f, -28.2f);
 HandAnim->RelativeRotation = FRotator(0.f, 0.f, -90.f);
 HandAnim->RelativeScale3D = FVector(0.7f, 0.7f, 0.7f);

Compiled / Saved etc.

Now back in my ATheForestCharacter I am trying to call method ShowPhoneLight() of the animation blueprint and here lies the problem:

 void ATheForestCharacter::BeginPlay()
     if (HandAnim)
         UHandAnimInstance* myHand = Cast<UHandAnimInstance>(HandAnim->GetAnimInstance());

This code always returns NULL into myHand.

Please note that even:

UAnimInstance* myHand = HandAnim->GetAnimInstance();

returns also NULL.

I’ve read many tutorials and threads and it sounds like the way to go so I believe I am missing something terrible obvious.

Any advice would be greatly appreciated.

Thank you!

Product Version: UE 4.8
more ▼

asked Jun 17 '15 at 07:35 PM in C++ Programming

avatar image

107 8 13 23

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

In my case "HandAnim" didn't have skeletal mesh assigned. Only the animation blueprint.

more ▼

answered Jul 24 '15 at 01:08 PM

avatar image

107 8 13 23

avatar image TiagoLing Jul 27 '15 at 01:24 PM

You did this in the editor or directly in code? Thanks! :)

avatar image TiagoLing Jul 27 '15 at 02:09 PM

Nevermind - just found out my problem: instead of setting "Anim Blueprint Generated Class" to my blueprint i was setting it directly to my custom AnimInstance parent class. I just read "class" in the field and didn't give it a second thought.

Thanks for your help!

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Nevermind - found a solution. You must have assigned skeletal mesh or this doesn't work.

more ▼

answered Jun 17 '15 at 08:56 PM

avatar image

107 8 13 23

avatar image TiagoLing Jul 24 '15 at 12:42 PM

Could you please elaborate more on your solution? I'm having the same problem, animation is always null, even though i have assigned a valid skeletal mesh in the editor.


(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question