From f57f6b8832a4b323923eccd443e3380af37b03a6 Mon Sep 17 00:00:00 2001 From: NisemonoQ Date: Fri, 17 Oct 2025 15:27:19 +0200 Subject: [PATCH] Minor - Ajout de la logique de Projectile au PlayerPawn MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Le playerPawn possède une fonction qui pourra appeler le script de projectile. Prochaine étape, complétion du système de Projectile. --- Content/CTP/03_Input/IA_Shoot.uasset | Bin 0 -> 1145 bytes Content/CTP/03_Input/IMC_Default.uasset | Bin 4540 -> 5198 bytes Source/M4_CPP/private/M4_PlayerPawn.cpp | 21 ++++++++++++++++++++- Source/M4_CPP/private/M4_Projectile.cpp | 2 +- Source/M4_CPP/public/M4_PlayerPawn.h | 5 +++++ 5 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 Content/CTP/03_Input/IA_Shoot.uasset diff --git a/Content/CTP/03_Input/IA_Shoot.uasset b/Content/CTP/03_Input/IA_Shoot.uasset new file mode 100644 index 0000000000000000000000000000000000000000..b2ce43d62666a92d93ddc700f22afad3f26ace00 GIT binary patch literal 1145 zcmX@utTpfZ|Ns9Jm>C$jm>3v-0%;IXxbl=Q}9K*`M24sK9 zT*@Q_Y0J%85rI>Ou``#)C2~v?syh~7*!y9fq{e!fMNR| z6mTFXdm_oP0{MRVd8rIvn2++x0yzPR$=QkNsXqD1i8+~7i6xo&d49m~EG|e)PGt}( zsq7#W#2Rk}W{Us~(hp89$}A|+cg`rTI61Ijw*Bo-Gll$2LY1ceSf?v%>wPx62SKvC+L400KRkVFCx2T%;^YKCI>4pAT% z9JHX|1p!4MCK$iKAOizXc!0n^V0f`Zm?$Jn9mrA`KnhNn5CbT@;T#|X&^H=TM}QQgNGbsZU~z~NPkP7^07_3F zJN$qtr7RT^bGAr2kz!vDEUQk?Omzk>paEftIi;x~l?AB`prCfj&j;p*JaF=bMFCJ4 l6&wT>BGbPuZP2qm0?MM`!T?!C**%LumQ(vR4WNP`^#JS1=eYm? literal 0 HcmV?d00001 diff --git a/Content/CTP/03_Input/IMC_Default.uasset b/Content/CTP/03_Input/IMC_Default.uasset index 2be9fca6bb5d9d671a14d539535c7c3c9726f1f2..0003bb637a0d4687e708af24a104c65566b010a8 100644 GIT binary patch delta 1202 zcmdm^d`@G6gxDixhvQ1Ex4$o0DA4)ihK=Z}<&!fH@J!Tmp*I5gAh3`dL4(x5_$PtlAbb;u^WW#yT)C*~-_aM86jk4;4>A{ImiENI z!AhJw3=C2t5JO<(e;_yj6qf-C$cbz&V)S4VSJM9H9-jVvPzlHr8;PHXZ+HsQ%@1$ZW>vk8bPLrnn1 zV<8)abAV@ZAeYqSAN*h?lViDfm~z=BUt|*#Qv)ghMIR_Ocp-`z428j}Z}7rZPqt^5 z04rreQ)-8)bUje1I#3z9souDiqMI6lskEO%LQDh6R9I-FVk-R)RSGi|rnDcoQf8>P zU`lu5R?32=^f5N29BRLTaSc=n2B4781Y-0M;T6FW&K#2?xQr(+U}K%!&85S378r{g zcqZ@VTFS-+G~qw<o%ayGBy zSMR((|$Ea_!V2?umMiyy^@L3^j~E0tlog*64&v zu`)1l0y*hy3=Hf*+8@XVfp9Ja4N?Q+R|CaCxEqM`-{;j_xv1*j(HE2yRo|%(G8bf) z`ozD%O1psyIs_qxz{vkVP{hr^APp4g5!_tF=)pAkG;=7U{A5KI@reoClhax3CU0Yz zH93dXwO$sgOAbo^1Zq}-vXRZjrcRkibt<^k@i8DOXtWe@PhQ9^HMx;pL(dE< z^bbiJC5Winm~NOfmmt__FllC>4v^De(k7_VENIekFlmFyE4U3O*Riut zzRRt_Ru4>kN!*jUd6u$)5_LVp8l9LU1H70BGdhz}S1|bhn z1Oy}|X9+n@KFnLi2$4_YbHkKpl$yLos1mATE ShootActionRef(TEXT("/Game/CTP/03_Input/IA_Shoot.IA_Shoot")); + if (ShootActionRef.Succeeded()) + { + ShootAction = ShootActionRef.Object; + } } void AM4_PlayerPawn::BeginPlay() @@ -64,10 +70,23 @@ void AM4_PlayerPawn::SetupPlayerInputComponent(UInputComponent* PlayerInputCompo { Input->BindAction(MoveAction, ETriggerEvent::Triggered, this, &AM4_PlayerPawn::Move); } + + if (ShootAction) + { + Input->BindAction(ShootAction, ETriggerEvent::Triggered, this, &AM4_PlayerPawn::Shoot); + } } } void AM4_PlayerPawn::Move(const FInputActionInstance& Instance) { LastMoveValue = Instance.GetValue().Get().GetSafeNormal(); -} \ No newline at end of file +} + +void AM4_PlayerPawn::Shoot(const FInputActionInstance& Inst) +{ + if (Inst.GetValue().Get() == true) + { + GEngine->AddOnScreenDebugMessage(-1, 2.f, FColor::Red, TEXT("Input Space Pressed")); + } +}; diff --git a/Source/M4_CPP/private/M4_Projectile.cpp b/Source/M4_CPP/private/M4_Projectile.cpp index 0f21fda..e481d10 100644 --- a/Source/M4_CPP/private/M4_Projectile.cpp +++ b/Source/M4_CPP/private/M4_Projectile.cpp @@ -11,7 +11,7 @@ AM4_Projectile::AM4_Projectile() MeshComp = CreateDefaultSubobject(TEXT("MeshComp")); MeshComp-> SetRelativeScale3D(FVector(1.f, .1f,.1f)); MeshComp->BodyInstance.SetCollisionProfileName(TEXT("Projectile")); - MeshComp->OnComponentHit.AddDynamic(this, &AM4_Projectile::OnHit); + MeshComp->OnComponentHit.AddDynamic(this, &AM4_Projectile::OnHit); } void AM4_Projectile::OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector Impulse, const FHitResult& Hit) diff --git a/Source/M4_CPP/public/M4_PlayerPawn.h b/Source/M4_CPP/public/M4_PlayerPawn.h index cd4ff8d..a123353 100644 --- a/Source/M4_CPP/public/M4_PlayerPawn.h +++ b/Source/M4_CPP/public/M4_PlayerPawn.h @@ -18,6 +18,7 @@ public: virtual void Tick(float DeltaTime) override; virtual void SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) override; void Move(const FInputActionInstance& Instance); + void Shoot(const FInputActionInstance& Inst); protected: @@ -27,6 +28,10 @@ protected: UPROPERTY() UInputAction* MoveAction; + UPROPERTY() + UInputAction* ShootAction; + + //bool HasShot = false; float MoveSpeed = 500.f; FVector2D MeshScale = FVector2D(0.6f, 0.5f); FVector2D LastMoveValue = FVector2D::ZeroVector;