# Weird issue with custom AnimNode

**URL:** <https://forums.unrealengine.com/t/weird-issue-with-custom-animnode/479491>\
**Category:** Character & Animation\
**Tags:** component-space, unreal-engine, question\
**Created:** [February 26, 2021, 7:24pm UTC](https://forums.unrealengine.com/t/weird-issue-with-custom-animnode/479491 "2021-02-26T19:24:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tangorn32](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@tangorn32](https://forums.unrealengine.com/u/tangorn32)\
**Post date:** [February 26, 2021, 7:24pm UTC](https://forums.unrealengine.com/t/weird-issue-with-custom-animnode/479491/1 "2021-02-26T19:24:06Z")

</div>

Hi,

I am playing around with custom AnimNode. I am not using SkeletalControlBase, just the regular AnimNodeBase to keep things simple. The code is also pretty simple:

```
    void 
    FAnimNodeNPC::Update_AnyThread(const FAnimationUpdateContext& Context)
    {
    	head.SetRotation(FQuat(0.3826834, 0.f, 0.f, 0.9238795));
    }
    
    FTransform
    FAnimNodeNPC::setBoneTransform(const FCompactPoseBoneIndex& boneIndex, const FTransform& newTransform, FComponentSpacePoseContext& context)
    {
    	FTransform newBoneTM;
    	FQuat rot = newTransform.GetRotation();
    	newBoneTM.SetRotation(rot);
    	const FTransform& boneTM = context.Pose.GetComponentSpaceTransform(boneIndex);
    	newBoneTM *= boneTM;
    	return newBoneTM;
    }
    
    void 
    FAnimNodeNPC::EvaluateComponentSpace_AnyThread(FComponentSpacePoseContext& Output)
    {
    	const FBoneContainer& boneContainer = Output.AnimInstanceProxy->GetRequiredBones();
    	Output.ResetToRefPose();
    
    	TArray<FBoneTransform> boneTransforms;
    
    	FName boneName = "head";
    	auto boneIndex = getBoneIndex(boneName, boneContainer);
    	boneTransforms.Add(FBoneTransform(boneIndex, setBoneTransform(boneIndex, head, Output)));
    
    	Output.Pose.SafeSetCSBoneTransforms(boneTransforms);
    }

```

As you can see it sets head rotation to 45 degrees to the right. That’s it. But, while it looks fine in the editor:

 ![331024-editorview.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/9/0/d908ca801a4947eba3ed9aaf2ef2b41c06472582.jpeg)

when in the game it shows 90 rotation instead of 45. Or generally, double any set rotation on the correct axis:

 ![331025-gameview.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/0/a/90a41f1145f0e9cbac78f8c39ed27cdaf0ee4729.jpeg)

I am pretty sure i am missing something simple here, can anybody please shed a light on it? Oh, and it is the same SkeletalMesh in editor and in game, just with a few facial morphs when in game.  
Interestingly, if instead of setting transform directly I pass in the HMD rotation, the character’s head follows the HMD perfectly, not with double angles… The reason that I even found the problem was the hands were messed up when following controllers…

---

<div class="post-metadata">

**Author:** ![tangorn32](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@tangorn32](https://forums.unrealengine.com/u/tangorn32)\
**Post date:** [March 1, 2021, 4:39pm UTC](https://forums.unrealengine.com/t/weird-issue-with-custom-animnode/479491/2 "2021-03-01T16:39:41Z")

</div>

never mind, totally my fault, unrelated to AnimNode. Was playing with multithreading and the turn was baked into reference pose from another thread before AnimNode was even initialized.
