Transformation applied to component space of a character model is not working as intended.

Hi, I’m trying to apply a bvh file I have to a character, and it’s not working as intended.

My plan is to apply the transformations in Component Space and then converting the result back to local space, and apply that to the output pose.

It looks like this.

I defined AnimGraphNode_CustomControl like this

class CLIENT_API UAnimGraphNode_CustomControl : public UAnimGraphNode_Base

    UPROPERTY(EditAnywhere, Category = Settings)
        FAnimNode_CustomControl Node;
    virtual void CreateOutputPins() final;

As you guys now, FAnimNode_CustomControl is where it inherits FAnimNode_Base and applies the animation to the character.

It’s defined as follows.

The header file

struct CLIENT_API FAnimNode_CustomControl : public FAnimNode_Base

    AFastCharacter* Character;

    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Links)
        FComponentSpacePoseLink Pose;
    virtual void Initialize_AnyThread(const FAnimationInitializeContext& Context) override;
    virtual void Update_AnyThread(const FAnimationUpdateContext& Context) override;
    virtual void EvaluateComponentSpace_AnyThread(FComponentSpacePoseContext& Output) override;


, I tried to make the neck look longer to the z axis direction. You can look at the following code to see what I mean.

The cpp file

#include "FAnimNode_CustomControl.h"
#include "AnimationRuntime.h"
#include "Animation/AnimInstanceProxy.h"

/*...Removed irrelevant code...*/

void FAnimNode_CustomControl::EvaluateComponentSpace_AnyThread(FComponentSpacePoseContext& Output)
    UE_LOG(LogTemp, Warning, TEXT("EvaluateComponentSpace_AnyThread Called"));

    if (Character != NULL && Character->State == 0 && Character->boneTransforms.Num() > 0) {
        UE_LOG(LogTemp, Warning, TEXT("SafeSetCSboneTransforms Called"));

        //Not sure if I have to write this column-wise or row-wise, but I guess row-wise is right?
        FMatrix temp=FMatrix::Identity;
        temp.M[3][0] = 0;
        temp.M[3][1] = 0;
        temp.M[3][2] = 1000;

        //Bone index 6 is where the head bone exists
        Output.Pose.SetComponentSpaceTransform(FCompactPoseBoneIndex(6), FTransform(temp));

This is the totally unexpected result.
It got extended to both the x axis AND the z axis direction!

I want to know why this happened and how I can possibly solve this. Any form of help would be appreciated a lot!!!

(My version is 4.24.1)

Skeletal joint space != world space.
I think you should look for a way to apply transformation in world space.

By Skeletal joint space, I assume you mean local space right? But isn’t component space different from local space? That’s what I understood here (Correct me if I’m wrong)…ion/index.html

Anyway, if I understood you correctly, I guess you’re saying the transformations in the component space (translation towards the z axis by 1000) is not gonna necessarily show on the world space as desired cause that z-axis is based on the component space’s z-axis. Hmmmm. Is there any way I can set the component space’s axis aligned with the world axis instead of being tilted? So that a translation in the z axis in component space is shown as the same in world space?

There must be a function in engine for that somewhere.
I just don’t know where or what it is called :slight_smile: