feat: rifle animations (in progress)

Added some rifle animations
Added weapon socket
This commit is contained in:
Kubson96 2025-06-17 01:31:12 +02:00
parent e5fc180630
commit 83aef1574c
21 changed files with 14 additions and 15 deletions

Binary file not shown.

View File

@ -116,14 +116,17 @@ void UShootingComponent::PickUpGun(UStaticMeshComponent* PickedGunMesh)
DropGun(); DropGun();
FAttachmentTransformRules AttachmentRules(EAttachmentRule::SnapToTarget, EAttachmentRule::SnapToTarget, FAttachmentTransformRules AttachmentRules(EAttachmentRule::SnapToTarget, EAttachmentRule::SnapToTarget,
EAttachmentRule::KeepRelative, true); EAttachmentRule::KeepWorld, true);
PickedGunMesh->SetSimulatePhysics(false); PickedGunMesh->SetSimulatePhysics(false);
PickedGunMesh->SetCastShadow(false); PickedGunMesh->SetCastShadow(false);
PickedGunMesh->AttachToComponent(PlayerCharacter->Weapon, AttachmentRules, FName(TEXT("GripPoint"))); PickedGunMesh->AttachToComponent(PlayerCharacter->GetMesh(), AttachmentRules, FName(TEXT("GripPoint")));
AGunBase* PickedGunBase = Cast<AGunBase>(PickedGunMesh->GetOwner()); AGunBase* PickedGunBase = Cast<AGunBase>(PickedGunMesh->GetOwner());
// Tymczasowo
bHasRifle = true;
if (IsValid(CurrentGunBase)) if (IsValid(CurrentGunBase))
{ {
SecondaryGunBase = PickedGunBase; SecondaryGunBase = PickedGunBase;
@ -176,13 +179,16 @@ void UShootingComponent::DropGun()
StopAiming(); StopAiming();
FDetachmentTransformRules DetachmentRules(EDetachmentRule::KeepRelative, EDetachmentRule::KeepRelative, FDetachmentTransformRules DetachmentRules(EDetachmentRule::KeepRelative, EDetachmentRule::KeepRelative,
EDetachmentRule::KeepRelative, false); EDetachmentRule::KeepWorld, false);
CurrentGunMesh->DetachFromComponent(DetachmentRules); CurrentGunMesh->DetachFromComponent(DetachmentRules);
CurrentGunMesh->SetSimulatePhysics(true); CurrentGunMesh->SetSimulatePhysics(true);
CurrentGunMesh->bCastDynamicShadow = true; CurrentGunMesh->bCastDynamicShadow = true;
CurrentGunMesh->CastShadow = true; CurrentGunMesh->CastShadow = true;
// Tymczasowo
bHasRifle = false;
CurrentGunMesh = nullptr; CurrentGunMesh = nullptr;
CurrentGunBase = nullptr; CurrentGunBase = nullptr;
} }

View File

@ -33,13 +33,6 @@ AExoPlayerCharacter::AExoPlayerCharacter()
InteractionComponent = CreateDefaultSubobject<UInteractionComponent>(TEXT("Interaction Component")); InteractionComponent = CreateDefaultSubobject<UInteractionComponent>(TEXT("Interaction Component"));
ShootingComponent = CreateDefaultSubobject<UShootingComponent>(TEXT("Shooting Component")); ShootingComponent = CreateDefaultSubobject<UShootingComponent>(TEXT("Shooting Component"));
Weapon = CreateDefaultSubobject<USkeletalMeshComponent>("Weapon");
Weapon->SetupAttachment(GetMesh());
Weapon->SetCollisionEnabled(ECollisionEnabled::NoCollision);
Weapon->bCastDynamicShadow = false;
Weapon->CastShadow = false;
Weapon->SetRelativeLocation(FVector(-50.f, 0.f, -90.f));
//bUseControllerRotationPitch = false; //bUseControllerRotationPitch = false;
//bUseControllerRotationYaw = true; //bUseControllerRotationYaw = true;
//bUseControllerRotationRoll = false; //bUseControllerRotationRoll = false;

View File

@ -90,6 +90,9 @@ public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Mele Attack") UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Mele Attack")
float MeleRange = 75.f; float MeleRange = 75.f;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Shooting")
bool bHasRifle = false;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Shooting") UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Shooting")
AThrowableBase* ThrowableItem = nullptr; AThrowableBase* ThrowableItem = nullptr;

View File

@ -21,9 +21,6 @@ public:
AExoPlayerCharacter(); AExoPlayerCharacter();
/// U PROPERTIES /// /// U PROPERTIES ///
UPROPERTY(EditAnywhere, Category = "Combat")
TObjectPtr<USkeletalMeshComponent> Weapon;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly) UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
TObjectPtr<UInteractionComponent> InteractionComponent; TObjectPtr<UInteractionComponent> InteractionComponent;
@ -60,8 +57,8 @@ public:
UPROPERTY(EditAnywhere, Category = "Movement Properties") UPROPERTY(EditAnywhere, Category = "Movement Properties")
float CrouchSpeed = 300.f; float CrouchSpeed = 300.f;
UPROPERTY(EditAnywhere, Category = "Aiming") UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Aiming")
float bIsAimingMode = false; bool bIsAimingMode = false;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Crouch") UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Crouch")
bool bIsCrouchingMode = false; bool bIsCrouchingMode = false;