Hey guys,
I have a custom UAnimInstance called MonoWheel_AnimBP and I’m using it to declare a few variables that I’m using on an animation blueprint that derives from this MonoWheel_AnimBP.
In this blueprint, I have a Blend Space 1D that controls the steering left/right of my character. I’m setting this value via C++, through the NativeUpdateAnimation function. I’ve called a UE_LOG to check if the value was being updated and it is, but I see no difference in the game.
Also, in the preview, if I change that value by hand, the character behaves just right (pictures below).
MonoWheel_AnimBP looks like this:
UCLASS(transient, Blueprintable, hideCategories = AnimInstance, BlueprintType)
class JOGODECARRO_API UMonoWheel_AnimBP : public UAnimInstance
{
public:
GENERATED_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Engine)
float steering;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Engine)
float wheelRPM;
virtual void NativeInitializeAnimation() override;
virtual void NativeUpdateAnimation(float DeltaTimeX) override;
AAMonoWheel *monowheel;
};
and it’s cpp file:
#include "MonoWheel_AnimBP.h"
void UMonoWheel_AnimBP::NativeInitializeAnimation()
{
Super::NativeInitializeAnimation();
monowheel = Cast<AAMonoWheel>(TryGetPawnOwner());
}
void UMonoWheel_AnimBP::NativeUpdateAnimation(float DeltaTimeX)
{
Super::NativeUpdateAnimation(DeltaTimeX);
if (monowheel)
{
UE_LOG(LogTemp, Warning, TEXT("MonoWheel is being set. current steering is %f"), steering); // this value gets updated.
steering = monowheel->currentSteering;
wheelRPM = monowheel->GetMonoWheelRPM();
}
}
The blueprint Anim Graph looks like this:
Also, when I update the steering value, I can see the preview changing:
Also I must point out that the value for wheelRPM works in game, it looks like the problem is specifically with the Blend Space 1D which doesn’t update.
Both wheelRPM and steering are the variables declared on my UAnimInstance.
Thank you!