54 - Aim Walking

This commit is contained in:
Kingsmedia 2022-05-03 19:50:47 +02:00
parent f8180073f1
commit 59856782f7
7 changed files with 30 additions and 5 deletions

Binary file not shown.

View File

@ -6,6 +6,7 @@
#include "Blaster/Components/CombatComponent.h"
#include "Blaster/Weapon/Weapon.h"
#include "Camera/CameraComponent.h"
#include "Components/CapsuleComponent.h"
#include "Components/WidgetComponent.h"
#include "GameFramework/CharacterMovementComponent.h"
#include "GameFramework/SpringArmComponent.h"
@ -35,6 +36,8 @@ ABlasterCharacter::ABlasterCharacter()
Combat->SetIsReplicated(true);
GetCharacterMovement()->NavAgentProps.bCanCrouch = true;
GetCapsuleComponent()->SetCollisionResponseToChannel(ECollisionChannel::ECC_Camera, ECollisionResponse::ECR_Ignore);
GetMesh()->SetCollisionResponseToChannel(ECollisionChannel::ECC_Camera, ECollisionResponse::ECR_Ignore);
}
void ABlasterCharacter::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const

View File

@ -12,17 +12,38 @@
UCombatComponent::UCombatComponent()
{
PrimaryComponentTick.bCanEverTick = false;
BaseWalkSpeed = 600.f;
AimWalkSpeed = 450.f;
}
void UCombatComponent::BeginPlay()
{
Super::BeginPlay();
if (Character)
{
Character->GetCharacterMovement()->MaxWalkSpeed = BaseWalkSpeed;
}
}
void UCombatComponent::SetAiming(bool bIsAiming)
{
bAiming = bIsAiming;
ServerSetAiming(bIsAiming);
if (Character)
{
Character->GetCharacterMovement()->MaxWalkSpeed = bIsAiming ? AimWalkSpeed : BaseWalkSpeed;
}
}
void UCombatComponent::ServerSetAiming_Implementation(bool bIsAiming)
{
bAiming = bIsAiming;
if (Character)
{
Character->GetCharacterMovement()->MaxWalkSpeed = bIsAiming ? AimWalkSpeed : BaseWalkSpeed;
}
}
void UCombatComponent::OnRep_EquippedWeapon()
@ -34,11 +55,6 @@ void UCombatComponent::OnRep_EquippedWeapon()
}
}
void UCombatComponent::ServerSetAiming_Implementation(bool bIsAiming)
{
bAiming = bIsAiming;
}
void UCombatComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);

View File

@ -39,4 +39,10 @@ private:
UPROPERTY(Replicated)
bool bAiming;
UPROPERTY(EditAnywhere)
float BaseWalkSpeed;
UPROPERTY(EditAnywhere)
float AimWalkSpeed;
};