antithing
(antithing)
August 26, 2016, 2:12pm
1
I am trying to set up custom anim graph nodes, and am struggling. The docs and every tutorial I can find:
After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — ue4community.wiki! You will be able to find content from the official...
Reading time: 1 mins 🕑
Likes: 13 ❤
After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — ue4community.wiki! You will be able to find content from the official...
Reading time: 1 mins 🕑
Likes: 13 ❤
Are outdated. In 4.12, the FAnimNode_Base class seems to have been replaced with: FAnimInstanceProxy, and neither of these are in the ‘create new c++ class’ list…
And this, I think, voids all the docs. What do I need to change in the above guides, to get custom anim nodes?
antithing
(antithing)
August 26, 2016, 4:41pm
2
Ah, I was missing the #include myGraphNode.h. It seems with this, the FAnimNode_Base can still be used.
Thumper
(Thumper)
September 6, 2017, 1:40pm
3
Any chance you could share how you were able to achieve this? I’m running through the links you posted trying to create an anim graph node and I’m running into lots of problems. Currently FBoneReference is not a blueprint type so I’m not sure how to expose that parameter.
antithing
(antithing)
September 6, 2017, 2:17pm
4
Sure! These are the files I use:
AnimGraphNode_NAME.cpp:
// Fill out your copyright notice in the Description page of Project Settings.
#include "YOUR_PLUGIN.h"
#include "AnimGraphNode_DataStream.h"
UAnimGraphNode_DataStream::UAnimGraphNode_DataStream(const class FObjectInitializer& PCIP)
: Super(PCIP)
{
}
FText UAnimGraphNode_DataStream::GetNodeTitle(ENodeTitleType::Type TitleType) const
{
return FText::FromString(FString::Printf(TEXT("NodeTitle.")));
}
FLinearColor UAnimGraphNode_DataStream::GetNodeTitleColor() const
{
return FLinearColor(0.75f, 0.75f, 0.75f);
}
FText UAnimGraphNode_DataStream::GetTooltipText() const
{
return FText::FromString(TEXT("ToolTipHere"));
}
FString UAnimGraphNode_DataStream::GetNodeCategory() const
{
return FString("Category");
}
antithing
(antithing)
September 6, 2017, 2:17pm
5
AnimNode_NAME.cpp
#include "YOUR_PLUGIN.h"
#include "Runtime/Engine/Public/Animation/AnimInstanceProxy.h"
#include "AnimNode_DataStream.h"
FAnimNode_NAME::FAnimNode_NAME()
{
}
FAnimNode_NAME::~FAnimNode_NAME()
{
}
void FAnimNode_NAME::Initialize(const FAnimationInitializeContext& Context)
{
// Forward to the incoming pose link.
check(Context.AnimInstanceProxy != nullptr);
//init the datastream
InPose.Initialize(Context);
}
TArray<FTransform> inPoses;
void FAnimNode_NAME::Update(const FAnimationUpdateContext& Context)
{
//this function should grab the data that you want on the skeleton and bind it.
//get input skelton Transforms and store
inPoses.Empty();
inPoses = Context.AnimInstanceProxy->GetSkelMeshComponent()->BoneSpaceTransforms;
InPose.Update(Context);
EvaluateGraphExposedInputs.Execute(Context);
}
void FAnimNode_NAME::Evaluate(FPoseContext& Output)
{
check(Output.AnimInstanceProxy->GetSkeleton() != nullptr);
InPose.Evaluate(Output);
//TempBones here is the output pose.
TArray<FTransform> TempBones = Output.Pose.GetBoneContainer().GetRefPoseArray();
TempBones[i].SetLocation(tmpV);
Output.Pose.CopyBonesFrom( TempBones );
return;
}
void FAnimNode_NAME::CacheBones(const FAnimationCacheBonesContext & Context)
{
InPose.CacheBones(Context);
}
antithing
(antithing)
September 6, 2017, 2:19pm
6
AnimGraphNode_NAME.h
#include "AnimNode_NAME.h"
#include "AnimGraphNode_Base.h"
#include "AnimGraphNode_NAME.generated.h"
/**
*
*/
UCLASS(MinimalAPI)
class AnimGraphNode_NAME : public UAnimGraphNode_Base
{
GENERATED_UCLASS_BODY()
//THIS IS CRUCIAL,
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Settings)
FAnimNode_NAME Node;
#if WITH_EDITOR
// UEdGraphNode interface
virtual FText GetNodeTitle(ENodeTitleType::Type TitleType) const override;
virtual FLinearColor GetNodeTitleColor() const override;
virtual FText GetTooltipText() const override;
virtual FString GetNodeCategory() const override;
// End of UEdGraphNode interface
#endif
};
antithing
(antithing)
September 6, 2017, 2:20pm
7
AnimNode_NAME.h
#pragma once
#include "Animation/AnimNodeBase.h"
//#include "AnimGraphNode_NAME.h"
#include "SkeletonBinding.h"
#include "AnimNode_NAME.generated.h"
USTRUCT()
struct FAnimNode_NAME : public FAnimNode_Base
{
GENERATED_USTRUCT_BODY()
public:
// The input pose is segmented into two:
// - The FK input pose that serves as a bias for the solver.
// - The task targets appended at the end.
//UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Links)
UPROPERTY(Transient)
FPoseLink InPose;
//these are boxes that show on the graph node
UPROPERTY(EditAnywhere, Category=Server, meta=(PinShownByDefault))
FString ServerName;
UPROPERTY(EditAnywhere, Category=Server,meta=(PinShownByDefault))
FString PortNumber;
public:
FAnimNode_DataStream();
~FAnimNode_DataStream();
// FAnimNode_Base interface
virtual void Initialize(const FAnimationInitializeContext& Context) override;
virtual void Update(const FAnimationUpdateContext& Context) override;
virtual void Evaluate(FPoseContext& Output) override;
virtual void CacheBones(const FAnimationCacheBonesContext & Context) override;
// End of FAnimNode_Base interface
private:
bool DoReconnect;
};
I am also trying to use those tutorials in 4.18 or 4.19 and cant get them to work. I tried your code here and UE4 cant find “AnimNode_DataStream” Has this been replaced in newer versions with something else?
antithing
(antithing)
April 14, 2018, 1:58pm
10
Heya, that is the name of my class. In the above example, that should be: #include "AnimNode_NAME.h"
VinayakP
(VinayakP)
June 16, 2020, 3:01am
11
Hi,
I’m still interested in this topic
I want to create a simple Anim Graph in C++, it can be as simple as an IDLE animation node connected to FINAL ANIMATION POSE via DEFAULTSLOT node