How to rotate bone in C++?

So, how would I go about rotating a bone in a Skeletal mesh?

In this example above I am rotating a single bone from CPP which controls the creatures torso twist.

#Custom Animation BP

Make a custom Anim BP class (AnimInstance.h)

Make custom c++ variables for each of your intended ways of manipulating bones

Make Skeletal Controller Nodes within your custom Animation Blueprint

Attach your custom cpp variables to the Animation BP Skel Controller nodes

now you have the interface for adjusting your skeleton in cpp, but being able to preview settings inside the editor for visual confirmation of whether you have the right axis/direction in mind.

#Wiki Tutorials

Anim BP Custom Logic via CPP


How would you go about setting the “Torso rotation” in C++ code? I’m trying to do the same but the bone is acting weird when i move the actor.

@Rama I want to do this for all skeletal bones. Here I have realtime motion capture data from a custom made system which has 17 bones. I just want to implement these data in a skeletalmesh. As you have mentioned before do I need to create 17 “Transform(Modify) Bone” functions to do this? And how to get each bone reference to this function?

Hi I found a way to manipulate one single bone of my vehicle using only c++ here is what I did :
the bones I want to manipulate is the front wheel of my vehicle ; “Wheel_Front_Left” and “Wheel_Front_Right”, I want to rotate it with a given angle
all what you need

//1. NormaleCar.h

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

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"

#include "Components/PoseableMeshComponent.h"
#include "NormaleCar.generated.h"

class UPoseableMeshComponent;

class RECVCREATEVEHICLE_API ANormaleCar : public AActor
	// Sets default values for this actor's properties

	// Called when the game starts or when spawned
	virtual void BeginPlay() override;

	// Called every frame
	virtual void Tick(float DeltaTime) override;


		//class USkeletalMeshComponent* SkeletalMesh;

		class UPoseableMeshComponent* PoseMesh;

	// Scale of the skeletal mesh
		float Scale = 3.0f;
// NormaleCar.cpp

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

#include “NormaleCar.h”

// Sets default values
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don’t need it.
PrimaryActorTick.bCanEverTick = true;

//SkeletalMesh = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("Sedan_SkelMesh"));
//static ConstructorHelpers::FObjectFinder<USkeletalMesh> ActorMesh(TEXT("/Game/VehicleVarietyPack/Skeletons/SK_NormalCar.SK_NormalCar"));

PoseMesh = CreateDefaultSubobject<UPoseableMeshComponent>(TEXT("PosebleMesh"));
static ConstructorHelpers::FObjectFinder<USkeletalMesh> ActorMesh(TEXT("/Game/VehicleVarietyPack/Skeletons/SK_NormalCar.SK_NormalCar"));

//static ConstructorHelpers::FObjectFinder<UPoseableMeshComponent> PPMesh(TEXT("/Game/VehicleVarietyPack/Skeletons/SK_NormalCar.SK_NormalCar"));

// The bone's location
//Location(10.0, 0.0, 0.0);
//Rotation(2.0, 1.0, 3.0, 4.0);


// Called when the game starts or when spawned
void ANormaleCar::BeginPlay()


// Called every frame
void ANormaleCar::Tick(float DeltaTime)
FVector Location(10.0, 10.0, 0.0);

//The bone's rotation
//FQuat Rotation1(0.0, 1.0, 1.0, 1.0);
FRotator Rotation(0.0, 0.0, 45.0);

FName WFL("Wheel_Front_Left");
FName WFR("Wheel_Front_Right");
//FTransform Transform(Rotation, Location, FVector(Scale));
PoseMesh->SetBoneRotationByName(WFL, Rotation, EBoneSpaces::ComponentSpace);
PoseMesh->SetBoneRotationByName(WFR, Rotation, EBoneSpaces::ComponentSpace);
//PoseMesh->SetBoneLocationByName(BoneName, Location, EBoneSpaces::ComponentSpace);
//PoseMesh->SetBoneTransformByName(BoneName, Transform, EBoneSpaces::ComponentSpace);


hope my code help someone