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.
// 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