Skip to content

Commit

Permalink
Temporary code for debugging ShadowfallStudios#258 shaking tool problem:
Browse files Browse the repository at this point in the history
    DedicatedServer rotation is driven by client RPC now, because curve driven rotation is only available when VisibilityBasedAnimTickOption is set to AlwaysTickPoseAndRefreshBones(AFAIK), so we need a more general approach. (it's a naive approach but should be enough for debugging, for a formal solution see CallServerMovePacked, FCharacterNetworkMoveData)
  • Loading branch information
ameaninglessname committed Oct 4, 2022
1 parent cb5a04e commit 3d66243
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
24 changes: 17 additions & 7 deletions Source/ALSV4_CPP/Private/Character/ALSBaseCharacter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,12 @@ void AALSBaseCharacter::UpdateGroundedRotation(const float DeltaTime)
}
else
{
if (IsNetMode(NM_DedicatedServer))
{
// DedicatedServer rotation is driven by client RPC
return;
}

if (GetLocalRole() == ROLE_SimulatedProxy)
{
// const FScopedPreventAttachedComponentMove PreventMeshMove(GetMesh());
Expand All @@ -1079,15 +1085,13 @@ void AALSBaseCharacter::UpdateGroundedRotation(const float DeltaTime)
if (const float RotAmountCurve = GetAnimCurveValue(NAME_RotationAmount);
FMath::Abs(RotAmountCurve) > 0.001f)
{
TargetRotation.Yaw = UKismetMathLibrary::NormalizeAxis(
TargetRotation.Yaw + (RotAmountCurve * (DeltaTime / (1.0f / 30.0f))));
SetActorRotation(TargetRotation);

if (GetLocalRole() == ROLE_AutonomousProxy)
{
TargetRotation.Yaw = UKismetMathLibrary::NormalizeAxis(
TargetRotation.Yaw + (RotAmountCurve * (DeltaTime / (1.0f / 30.0f))));
SetActorRotation(TargetRotation);
}
else
{
AddActorWorldRotation({0, RotAmountCurve * (DeltaTime / (1.0f / 30.0f)), 0});
Server_SetActorRotation(TargetRotation);
}
TargetRotation = GetActorRotation();
}
Expand All @@ -1105,6 +1109,12 @@ void AALSBaseCharacter::UpdateGroundedRotation(const float DeltaTime)
// Other actions are ignored...
}

void AALSBaseCharacter::Server_SetActorRotation_Implementation(const FRotator Rotator)
{
TargetRotation = Rotator;
SetActorRotation(Rotator);
}

void AALSBaseCharacter::UpdateInAirRotation(const float DeltaTime)
{
if (RotationMode == EALSRotationMode::VelocityDirection || RotationMode == EALSRotationMode::LookingDirection)
Expand Down
3 changes: 3 additions & 0 deletions Source/ALSV4_CPP/Public/Character/ALSBaseCharacter.h
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,9 @@ class ALSV4_CPP_API AALSBaseCharacter : public ACharacter

void UpdateGroundedRotation(float DeltaTime);

UFUNCTION(Server, Reliable)
void Server_SetActorRotation(const FRotator Rotator);

void UpdateInAirRotation(float DeltaTime);

/** Utils */
Expand Down

0 comments on commit 3d66243

Please sign in to comment.