How to call a Anim Node Reference from code?

Hi!
I have a Anim Node Reference in the AnimGraph (screen 1). It is called both in the AnimGraph and in the EventGraph (screen 2, I’ll attach as a separate message). I want to rewrite the EventGraph from BP to C++ code, but I don’t understand how I can call this Anim Node Reference from the code. The Anim Node Reference has a Tag OffsetRoot.
Has anyone done this before?

UE version - 5.5.3

Screen 2

Hey,

So what you are looking for is an FAnimNodeReference, there is a construct where you pass the animation instance and the node you want ref.

Bye.

Hi!
This is the first method I tried. In this case, I can’t set the value in it
image
My code

UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Anim|Essential Values")
FAnimNodeReference OffsetRootNode;

Why not just pass it in?

just make sure you use BlueprintReadWrite to able to write to it
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Anim | Essential Values")

Yes, you can.

Set on its declaration: FAnimNodeReference OffsetRootNode{AnimInstance, YourRefNode}, that may compile.

In case you get any error when opening your engine, that’s because your anim instance is not inicialized yet, so you can turn that arround seting your OffsetRootNode onNativeInitializeAnimation, simple:

OffsetRootNode = FAnimNodeReference(this, YourRefNode);

I think that may solve this problem.

Bye.

1 Like

FAnimNode_Base is not exposed to blueprints so it might need some scaffolding to be callable from the anim graph

Main question though => what do you want to achieve from accessing it in c++? Do you want to modify it’s parameters?

I have this event disabled in the BP now, since I moved everything to code. But for now I did it roughly the same way)

My code

UFUNCTION(BlueprintImplementableEvent, Category = "Anim|Essential Values")
FAnimNodeReference GetOffsetRootNode();

And no, I’m not modifying this Node in the code. I just wanted to know if there was a more humane solution.
Apparently, the current solution is enough.
Thanks to everyone for the help)

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.