diff --git a/Content/Blueprints/Character/Animation/AimWalk.uasset b/Content/Blueprints/Character/Animation/AimWalk.uasset new file mode 100644 index 0000000..022b113 Binary files /dev/null and b/Content/Blueprints/Character/Animation/AimWalk.uasset differ diff --git a/Content/Blueprints/Character/Animation/BlasterAnimBP.uasset b/Content/Blueprints/Character/Animation/BlasterAnimBP.uasset index 61a7ed7..801f739 100644 Binary files a/Content/Blueprints/Character/Animation/BlasterAnimBP.uasset and b/Content/Blueprints/Character/Animation/BlasterAnimBP.uasset differ diff --git a/Content/Blueprints/Character/Animation/CrouchAimWalk.uasset b/Content/Blueprints/Character/Animation/CrouchAimWalk.uasset new file mode 100644 index 0000000..9c1c1cb Binary files /dev/null and b/Content/Blueprints/Character/Animation/CrouchAimWalk.uasset differ diff --git a/Content/Blueprints/Character/BP_BlasterCharacter.uasset b/Content/Blueprints/Character/BP_BlasterCharacter.uasset index 5982972..d51a665 100644 Binary files a/Content/Blueprints/Character/BP_BlasterCharacter.uasset and b/Content/Blueprints/Character/BP_BlasterCharacter.uasset differ diff --git a/Source/Blaster/Character/BlasterCharacter.cpp b/Source/Blaster/Character/BlasterCharacter.cpp index 3d336ab..d3a7636 100644 --- a/Source/Blaster/Character/BlasterCharacter.cpp +++ b/Source/Blaster/Character/BlasterCharacter.cpp @@ -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& OutLifetimeProps) const diff --git a/Source/Blaster/Components/CombatComponent.cpp b/Source/Blaster/Components/CombatComponent.cpp index 1913422..2b6ae79 100644 --- a/Source/Blaster/Components/CombatComponent.cpp +++ b/Source/Blaster/Components/CombatComponent.cpp @@ -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); diff --git a/Source/Blaster/Components/CombatComponent.h b/Source/Blaster/Components/CombatComponent.h index 54df2c8..7bf4d7f 100644 --- a/Source/Blaster/Components/CombatComponent.h +++ b/Source/Blaster/Components/CombatComponent.h @@ -39,4 +39,10 @@ private: UPROPERTY(Replicated) bool bAiming; + + UPROPERTY(EditAnywhere) + float BaseWalkSpeed; + + UPROPERTY(EditAnywhere) + float AimWalkSpeed; };