54 - Aim Walking
This commit is contained in:
parent
f8180073f1
commit
59856782f7
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -39,4 +39,10 @@ private:
|
|||
|
||||
UPROPERTY(Replicated)
|
||||
bool bAiming;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
float BaseWalkSpeed;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
float AimWalkSpeed;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue