Compare commits
2 Commits
main
...
f57f6b8832
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f57f6b8832 | ||
|
|
8733dfd87f |
BIN
Content/CTP/03_Input/IA_Shoot.uasset
Normal file
BIN
Content/CTP/03_Input/IA_Shoot.uasset
Normal file
Binary file not shown.
Binary file not shown.
@@ -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"));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user