diff --git a/Content/CTP/03_Input/IA_Shoot.uasset b/Content/CTP/03_Input/IA_Shoot.uasset new file mode 100644 index 0000000..b2ce43d Binary files /dev/null and b/Content/CTP/03_Input/IA_Shoot.uasset differ diff --git a/Content/CTP/03_Input/IMC_Default.uasset b/Content/CTP/03_Input/IMC_Default.uasset index 2be9fca..0003bb6 100644 Binary files a/Content/CTP/03_Input/IMC_Default.uasset and b/Content/CTP/03_Input/IMC_Default.uasset differ diff --git a/Source/M4_CPP/private/M4_PlayerPawn.cpp b/Source/M4_CPP/private/M4_PlayerPawn.cpp index 8a42c66..6c80f23 100644 --- a/Source/M4_CPP/private/M4_PlayerPawn.cpp +++ b/Source/M4_CPP/private/M4_PlayerPawn.cpp @@ -32,6 +32,12 @@ AM4_PlayerPawn::AM4_PlayerPawn() { MoveAction = MoveActionRef.Object; } + + static ConstructorHelpers::FObjectFinder 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;