fix: some bugs fixed

Fixed aiming when crouching reset velocity bug.
Fixed laying weapon disappearing in some cases.
This commit is contained in:
Kubson96 2025-07-04 13:01:56 +02:00
parent e1b383b28f
commit 93c5e9d82c
5 changed files with 10 additions and 3 deletions

Binary file not shown.

View File

@ -114,7 +114,7 @@ void UShootingComponent::PickUpGun(UStaticMeshComponent* PickedGunMesh)
{
if (IsValid(CurrentGunBase) && IsValid(SecondaryGunBase))
DropGun();
FAttachmentTransformRules AttachmentRules(EAttachmentRule::SnapToTarget, EAttachmentRule::SnapToTarget,
EAttachmentRule::KeepWorld, true);
@ -183,6 +183,7 @@ void UShootingComponent::DropGun()
CurrentGunMesh->DetachFromComponent(DetachmentRules);
CurrentGunMesh->SetSimulatePhysics(true);
CurrentGunMesh->SetCollisionResponseToChannel(ECC_Visibility, ECR_Block);
CurrentGunMesh->bCastDynamicShadow = true;
CurrentGunMesh->CastShadow = true;
@ -268,7 +269,9 @@ void UShootingComponent::StartAiming()
if (IsValid(CurrentGunBase))
{
PlayerCharacter->bIsAimingMode = true;
PlayerCharacter->GetCharacterMovement()->MaxWalkSpeed = PlayerCharacter->WalkSpeed * AimingMoveSpeedScale;
if (!PlayerCharacter->bIsCrouchingMode)
PlayerCharacter->GetCharacterMovement()->MaxWalkSpeed = PlayerCharacter->WalkSpeed * AimingMoveSpeedScale;
TargetFOV = CurrentGunBase->AimingFOV;
OnStartedADS.Broadcast();
@ -278,7 +281,11 @@ void UShootingComponent::StartAiming()
void UShootingComponent::StopAiming()
{
PlayerCharacter->bIsAimingMode = false;
PlayerCharacter->GetCharacterMovement()->MaxWalkSpeed = PlayerCharacter->WalkSpeed;
if (PlayerCharacter->bIsCrouchingMode)
PlayerCharacter->GetCharacterMovement()->MaxWalkSpeed = PlayerCharacter->CrouchSpeed;
else
PlayerCharacter->GetCharacterMovement()->MaxWalkSpeed = PlayerCharacter->WalkSpeed;
TargetFOV = DefaultFOV;