Skip to content

Commit

Permalink
Fix #218. Prevent spamming SetMovementSettings on movement component …
Browse files Browse the repository at this point in the history
…by turning the call into event based.
  • Loading branch information
dyanikoglu committed May 19, 2021
1 parent 5eb4d3a commit 89f3363
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Source/ALSV4_CPP/Private/Character/ALSBaseCharacter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ void AALSBaseCharacter::BeginPlay()
MainAnimInstance->SetRootMotionMode(ERootMotionMode::IgnoreRootMotion);
}

MyCharacterMovementComponent->SetMovementSettings(GetTargetMovementSettings());

DebugComponent = FindComponentByClass<UALSDebugComponent>();
}

Expand Down Expand Up @@ -877,6 +879,8 @@ void AALSBaseCharacter::OnStanceChanged(const EALSStance PreviousStance)
{
CameraBehavior->Stance = Stance;
}

MyCharacterMovementComponent->SetMovementSettings(GetTargetMovementSettings());
}

void AALSBaseCharacter::OnRotationModeChanged(EALSRotationMode PreviousRotationMode)
Expand All @@ -893,6 +897,8 @@ void AALSBaseCharacter::OnRotationModeChanged(EALSRotationMode PreviousRotationM
{
CameraBehavior->SetRotationMode(RotationMode);
}

MyCharacterMovementComponent->SetMovementSettings(GetTargetMovementSettings());
}

void AALSBaseCharacter::OnGaitChanged(const EALSGait PreviousGait)
Expand Down Expand Up @@ -1074,9 +1080,6 @@ void AALSBaseCharacter::UpdateCharacterMovement()
SetGait(ActualGait);
}

// Get the Current Movement Settings and pass it through to the movement component.
MyCharacterMovementComponent->SetMovementSettings(GetTargetMovementSettings());

// Update the Character Max Walk Speed to the configured speeds based on the currently Allowed Gait.
MyCharacterMovementComponent->SetAllowedGait(AllowedGait);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ void UALSCharacterMovementComponent::SetMovementSettings(FALSMovementSettings Ne
{
// Set the current movement settings from the owner
CurrentMovementSettings = NewMovementSettings;
bRequestMovementSettingsChange = true;
}

void UALSCharacterMovementComponent::SetAllowedGait(EALSGait NewAllowedGait)
Expand Down

0 comments on commit 89f3363

Please sign in to comment.