# GAS/Motion Matching - controlling rotation through code?

**URL:** <https://forums.unrealengine.com/t/gas-motion-matching-controlling-rotation-through-code/2184147>\
**Category:** Programming & Scripting\
**Tags:** rotation, controller, unreal-engine, question\
**Created:** [December 8, 2024, 3:38pm UTC](https://forums.unrealengine.com/t/gas-motion-matching-controlling-rotation-through-code/2184147 "2024-12-08T15:38:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![matan19](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@matan19](https://forums.unrealengine.com/u/matan19)\
**Post date:** [December 8, 2024, 3:38pm UTC](https://forums.unrealengine.com/t/gas-motion-matching-controlling-rotation-through-code/2184147/1 "2024-12-08T15:38:11Z")

</div>

I’ve looked into GAS and motion matching, and I need code that will rotate the character, when the player has no control on it. He should however still have control of the camera.

I tried many settings, but I can’t seem to get it.  
The character seems to always follow the control rotation, which seems to match the camera rotation.

I hope someone here knows how to accomplish this 🙏

---

<div class="post-metadata">

**Author:** ![ZkarmaKun](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/zkarmakun/32/1194545_2.png) [@ZkarmaKun](https://forums.unrealengine.com/u/ZkarmaKun)\
**Post date:** [December 16, 2025, 12:06am UTC](https://forums.unrealengine.com/t/gas-motion-matching-controlling-rotation-through-code/2184147/2 "2025-12-16T00:06:37Z")

</div>

Looking for the same, a quick look into the class UCharacterTrajectoryComponent take me to this:

void FCharacterTrajectoryData::UpdateDataFromCharacter(float DeltaSeconds, const ACharacter\* Character)  
{  
if (!ensure(Character))  
{  
return;  
}

```
// An AnimInstance might call this during an AnimBP recompile with 0 delta time.
if (DeltaSeconds <= 0.f)
{
   return;
}

if (const UCharacterMovementComponent\* MoveComp = Character->GetCharacterMovement())
{
   MaxSpeed = FMath::Max(MoveComp->GetMaxSpeed() \* MoveComp->GetAnalogInputModifier(), MoveComp->GetMinAnalogSpeed());
   BrakingDeceleration = FMath::Max(0.f, MoveComp->GetMaxBrakingDeceleration());
   bOrientRotationToMovement = MoveComp->bOrientRotationToMovement;

   Velocity = MoveComp->Velocity;
   Acceleration = MoveComp->GetCurrentAcceleration();

   if (Acceleration.IsZero())
   {
      Friction = MoveComp->bUseSeparateBrakingFriction ? MoveComp->BrakingFriction : MoveComp->GroundFriction;
      const float FrictionFactor = FMath::Max(0.f, MoveComp->BrakingFrictionFactor);
      Friction = FMath::Max(0.f, Friction \* FrictionFactor);
   }
   else
   {
      Friction = MoveComp->GroundFriction;
   }
}
else
{
   ensure(false);
}

// @todo: Simulated proxies don't have controllers, so they'll need some other mechanism to account for controller rotation rate.
const AController\* Controller = Character->GetController();
if (Controller)
{
   float DesiredControllerYaw = Controller->GetDesiredRotation().Yaw;
   
   const float DesiredYawDelta = DesiredControllerYaw - DesiredControllerYawLastUpdate;
   DesiredControllerYawLastUpdate = DesiredControllerYaw;

   ControllerYawRate = FRotator::NormalizeAxis(DesiredYawDelta) \* (1.f / DeltaSeconds);
   ControllerYawRateClamped = ControllerYawRate;
   if (MaxControllerYawRate >= 0.f)
   {
      ControllerYawRateClamped = FMath::Sign(ControllerYawRate) \* FMath::Min(FMath::Abs(ControllerYawRate), MaxControllerYawRate);
   }
}

if (const USkeletalMeshComponent\* MeshComp = Character->GetMesh())
{
   Position = MeshComp->GetComponentLocation();
   Facing = MeshComp->GetComponentRotation().Quaternion();
   MeshCompRelativeRotation = MeshComp->GetRelativeRotation().Quaternion();
}
else
{
   ensure(false);
}

```

}

Where as you can se the ControllerYawRate only obeys the Control rotation, same with the Search pose node, you need to go c++ in order to fix this AFAIK
