Hi, I created this class of AnimInstance:
#include "Animation/AnimInstance.h"
#include "UAAnimInstance.generated.h"
/**
*
*/
UCLASS(Transient, Blueprintable, HideCategories = AnimInstance, BlueprintType)
class ULTIMATEARENA_API UUAAnimInstance : public UAnimInstance
{
GENERATED_UCLASS_BODY()
/** Variables declaration */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Movement")
float Speed;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Movement")
float ForwardSpeed;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Movement")
float RightSpeed;
};
and I want to set the Speed, ForwardSpeed and RightSpeed variables externally (from the UACharacter class).
So on the UACharacter class I included “UAAnimInstance.h”, and I added this under the Event Tick:
UUAAnimInstance* Animation = Cast<UUAAnimInstance>(Mesh->GetAnimInstance());
if (!Animation)
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "ERROR: Anim Instance not loaded.");
return;
}
But the problem is that if I play, I see “ERROR: Anim Instance not loaded”, so the Animation variable is not set.
How can I solve this problem?
I followed the Rama’s tutorial here: A new, community-hosted Unreal Engine Wiki - Announcements - Unreal Engine Forums