Compare commits

...

2 Commits

Author SHA1 Message Date
NisemonoQ
f57f6b8832 Minor - Ajout de la logique de Projectile au PlayerPawn
Le playerPawn possède une fonction qui pourra appeler le script de projectile.
Prochaine étape, complétion du système de Projectile.
2025-10-17 15:27:19 +02:00
NisemonoQ
8733dfd87f Merge branch 'main' into Bullet 2025-10-17 14:02:35 +02:00
5 changed files with 26 additions and 2 deletions

Binary file not shown.

View File

@@ -32,6 +32,12 @@ AM4_PlayerPawn::AM4_PlayerPawn()
{
MoveAction = MoveActionRef.Object;
}
static ConstructorHelpers::FObjectFinder<UInputAction> 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<FVector2D>().GetSafeNormal();
}
}
void AM4_PlayerPawn::Shoot(const FInputActionInstance& Inst)
{
if (Inst.GetValue().Get<bool>() == true)
{
GEngine->AddOnScreenDebugMessage(-1, 2.f, FColor::Red, TEXT("Input Space Pressed"));
}
};

View File

@@ -11,7 +11,7 @@ AM4_Projectile::AM4_Projectile()
MeshComp = CreateDefaultSubobject<UStaticMeshComponent>(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)

View File

@@ -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;