Custom Anim Node: Where do I place bone transform code?

Hi guys,

I want to re-create a simple blueprint-based VR IK setup, but written in C++. I’ve been mirroring the Blueprint process in C++, and so far so good. It turns out that I can’t easily type everything out in C++ and have it all run. Instead, it looks like I’ll do most of the heavy lifting in C++ and pass over all of that heavy lifting in the form of a custom Anim Graph Node. However, I don’t understand the structure of the custom Anim Node, which means that I don’t know where to type the IK logic code.

The idea I’m going after is pretty simple. The blueprint-based Simple VR IK works like this:

1) It stores the motion controller transforms in the EventGraph portion of the Anim Instance.

1.a) I mirrored this process by creating my own custom Anim Instance in C

// Fill out your copyright notice in the Description page of Project Settings.

#include "MyVRAnimInstance.h"
#include "CoreMinimal.h"
#include "GameFramework/Pawn.h"
#include "GameFramework/Actor.h"
#include "VRPawn.h"
#include "Engine/Classes/Animation/AnimInstance.h"
#include "Runtime/HeadMountedDisplay/Public/MotionControllerComponent.h"

	Speed = 0.0;

void UMyVRAnimInstance::NativeUpdateAnimation(float DeltaSeconds)
	AActor* OwningActor = GetOwningActor();
	APawn* PawnOwner = TryGetPawnOwner();
	AVRPawn* myVRpawn;


	myVRpawn = Cast<AVRPawn>(PawnOwner);
	if(OwningActor != nullptr)
		Speed = OwningActor->GetVelocity().Size();
	if (PawnOwner != nullptr && myVRpawn != nullptr)
		LMotionControllerTransform = myVRpawn->LeftMotionController->GetComponentTransform();
		RMotionControllerTransform = myVRpawn->RightMotionController->GetComponentTransform();


2) The simple blueprint VR IK example then pulls the Motion Controller transforms within the AnimGraph section of the Anim Instance, and applies FABRIK IK logic to it.

2.a) In an attempt to mirror the process above, I created an empty shell of a custom AnimNode. However, I don’t know where to place the FABRIK logic. Where do I place the FABRIK logic? In which section of my Custom Anim Node? Below i include an image of the Theoretical AnimGraphNode (right now it’s just a shell, but this is how I envision it working). Further below that, I am including my custom Anim Node cpp file.

Where do I place the FABRIK functions and how do I return them back out from the node, as in the image above?

// Fill out your copyright notice in the Description page of Project Settings.

#include "MyAnimNode.h"
#include "CoreMinimal.h"
#include "MyVRGame.h"
#include "Animation/AnimInstanceProxy.h"



void FMyAnimNode::Initialize_AnyThread(const FAnimationInitializeContext& Context) 

void FMyAnimNode::CacheBones_AnyThread(const FAnimationCacheBonesContext& Context) 

void FMyAnimNode::Update_AnyThread(const FAnimationUpdateContext& Context) 

void FMyAnimNode::Evaluate_AnyThread(FPoseContext& Output) 
	// Evaluate the input

void FMyAnimNode::GatherDebugData(FNodeDebugData& DebugData) {
	FString DebugLine = DebugData.GetNodeName(this);



Hi! Animation main points in Unreal are

  1. Evaluation Nodes, that are used in AnimInstances and AnimInstanceProxies are here
    They are used as blocks to modify bone pose

  2. Editor Nodes, they are used only to config animation with Unreal Editor in Anim Blueprint and in fact generate Evaluation Nodes.

So, animation pipe is roughly

  • Create AnimationBlueprint and create some special graph of Editor Nodes.
  • After that Graph of Editor Nodes compiles to graph of Evaluation Nodes
  • This graph of Evaluation Nodes is used by AnimInstance to animate Skeletal meshes

If your question is where to place bone transform code, simply look at this base class

Thank you! Yup it looks like I gotta put it in the Evaluate override. As I’ve been reading and looking up more info on this, now, I’m not sure if I should be using AnimNode_Base or AnimNode_SkeletalControlBase… But, one step at a time! Thank you Kehel!