From 887d10b7eb9176e5c9261528053f727f2cc8a073 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Do=C4=9Fa=20Can=20Yan=C4=B1ko=C4=9Flu?= Date: Thu, 18 Feb 2021 01:23:44 +0300 Subject: [PATCH] Get rolling rotation in domain of networked game optimizations, disable it on networked games for now --- .../Private/Character/ALSBaseCharacter.cpp | 26 +++++++++---------- .../Public/Character/ALSBaseCharacter.h | 12 ++++----- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Source/ALSV4_CPP/Private/Character/ALSBaseCharacter.cpp b/Source/ALSV4_CPP/Private/Character/ALSBaseCharacter.cpp index 0e7836fe..97e13128 100644 --- a/Source/ALSV4_CPP/Private/Character/ALSBaseCharacter.cpp +++ b/Source/ALSV4_CPP/Private/Character/ALSBaseCharacter.cpp @@ -84,11 +84,11 @@ void AALSBaseCharacter::OnBreakfall_Implementation() Replicated_PlayMontage(GetRollAnimation(), 1.35); } -void AALSBaseCharacter::Replicated_PlayMontage_Implementation(UAnimMontage* Montage, float Track) +void AALSBaseCharacter::Replicated_PlayMontage_Implementation(UAnimMontage* Montage, float PlayRate) { // Roll: Simply play a Root Motion Montage. - MainAnimInstance->Montage_Play(Montage, Track); - Server_PlayMontage(Montage, Track); + MainAnimInstance->Montage_Play(Montage, PlayRate); + Server_PlayMontage(Montage, PlayRate); } void AALSBaseCharacter::BeginPlay() @@ -96,7 +96,7 @@ void AALSBaseCharacter::BeginPlay() Super::BeginPlay(); // If we're in networked game, disable curved movement - bDisableCurvedMovement = !IsNetMode(NM_Standalone); + bEnableNetworkOptimizations = !IsNetMode(NM_Standalone); // Make sure the mesh and animbp update after the CharacterBP to ensure it gets the most recent values. GetMesh()->AddTickPrerequisiteActor(this); @@ -463,17 +463,18 @@ void AALSBaseCharacter::EventOnJumped() MainAnimInstance->OnJumped(); } -void AALSBaseCharacter::Server_PlayMontage_Implementation(UAnimMontage* Montage, float Track) +void AALSBaseCharacter::Server_PlayMontage_Implementation(UAnimMontage* Montage, float PlayRate) { - Multicast_PlayMontage(Montage, Track); + MainAnimInstance->Montage_Play(Montage, PlayRate); + ForceNetUpdate(); + Multicast_PlayMontage(Montage, PlayRate); } -void AALSBaseCharacter::Multicast_PlayMontage_Implementation(UAnimMontage* Montage, float Track) +void AALSBaseCharacter::Multicast_PlayMontage_Implementation(UAnimMontage* Montage, float PlayRate) { if (!IsLocallyControlled()) { - // Roll: Simply play a Root Motion Montage. - MainAnimInstance->Montage_Play(Montage, Track); + MainAnimInstance->Montage_Play(Montage, PlayRate); } } @@ -955,7 +956,7 @@ void AALSBaseCharacter::UpdateCharacterMovement() } // Use the allowed gait to update the movement settings. - if (bDisableCurvedMovement) + if (bEnableNetworkOptimizations) { // Don't use curves for movement UpdateDynamicMovementSettingsNetworked(AllowedGait); @@ -1075,9 +1076,8 @@ void AALSBaseCharacter::UpdateGroundedRotation(float DeltaTime) } else if (MovementAction == EALSMovementAction::Rolling) { - // Rolling Rotation - - if (bHasMovementInput) + // Rolling Rotation (Not allowed on networked games) + if (!bEnableNetworkOptimizations && bHasMovementInput) { SmoothCharacterRotation({0.0f, LastMovementInputRotation.Yaw, 0.0f}, 0.0f, 2.0f, DeltaTime); } diff --git a/Source/ALSV4_CPP/Public/Character/ALSBaseCharacter.h b/Source/ALSV4_CPP/Public/Character/ALSBaseCharacter.h index 3f975ebb..b2869b3d 100644 --- a/Source/ALSV4_CPP/Public/Character/ALSBaseCharacter.h +++ b/Source/ALSV4_CPP/Public/Character/ALSBaseCharacter.h @@ -150,10 +150,10 @@ class ALSV4_CPP_API AALSBaseCharacter : public ACharacter /** Rolling Montage Play Replication*/ UFUNCTION(BlueprintCallable, Server, Reliable, Category = "ALS|Character States") - void Server_PlayMontage(UAnimMontage* Montage, float Track); + void Server_PlayMontage(UAnimMontage* Montage, float PlayRate); UFUNCTION(BlueprintCallable, NetMulticast, Reliable, Category = "ALS|Character States") - void Multicast_PlayMontage(UAnimMontage* Montage, float Track); + void Multicast_PlayMontage(UAnimMontage* Montage, float PlayRate); /** Ragdolling*/ UFUNCTION(BlueprintCallable, Category = "ALS|Character States") @@ -241,8 +241,8 @@ class ALSV4_CPP_API AALSBaseCharacter : public ACharacter /** BP implementable function that called when A Montage starts, e.g. during rolling */ UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "ALS|Movement System") - void Replicated_PlayMontage(UAnimMontage* montage, float track); - virtual void Replicated_PlayMontage_Implementation(UAnimMontage* montage, float track); + void Replicated_PlayMontage(UAnimMontage* Montage, float PlayRate); + virtual void Replicated_PlayMontage_Implementation(UAnimMontage* Montage, float PlayRate); /** Implement on BP to get required roll animation according to character's state */ UFUNCTION(BlueprintCallable, BlueprintImplementableEvent, Category = "ALS|Movement System") @@ -629,6 +629,6 @@ class ALSV4_CPP_API AALSBaseCharacter : public ACharacter /* Smooth out aiming by interping control rotation*/ FRotator AimingRotation = FRotator::ZeroRotator; - /** We won't use curve based movement on networked games */ - bool bDisableCurvedMovement = false; + /** We won't use curve based movement and a few other features on networked games */ + bool bEnableNetworkOptimizations = false; };