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
{
GENERATED_BODY()
UPROPERTY(EditDefaultsOnly, Category = Phone)
UAnimMontage* _phoneOn;
UPROPERTY(EditDefaultsOnly, Category = Phone)
UAnimMontage* _phoneOff;
public:
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->SetOnlyOwnerSee(true);
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()
{
Super::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!