타격(hit) 이벤트
This commit is contained in:
parent
4da7802d04
commit
69d31cd28a
BIN
Content/Blueprints/Actors/BP_Projectile.uasset
(Stored with Git LFS)
BIN
Content/Blueprints/Actors/BP_Projectile.uasset
(Stored with Git LFS)
Binary file not shown.
@ -15,12 +15,14 @@ AProjectile::AProjectile()
|
||||
ProjectileMovement = CreateDefaultSubobject<UProjectileMovementComponent>(TEXT("Projectile Movement"));
|
||||
ProjectileMovement->InitialSpeed = 400.0f;
|
||||
ProjectileMovement->MaxSpeed = 1000.0f;
|
||||
|
||||
}
|
||||
|
||||
// Called when the game starts or when spawned
|
||||
void AProjectile::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
ProjectileMesh->OnComponentHit.AddDynamic(this, &AProjectile::OnHit);
|
||||
|
||||
}
|
||||
|
||||
@ -31,3 +33,10 @@ void AProjectile::Tick(float DeltaTime)
|
||||
|
||||
}
|
||||
|
||||
void AProjectile::OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit)
|
||||
{
|
||||
UE_LOG(LogTemp, Warning, TEXT("HitComp: %s, Other Actor: %s, Other Comp: %s"),
|
||||
*HitComp->GetName(), *OtherActor->GetName(), *OtherComp->GetName());
|
||||
}
|
||||
|
||||
|
||||
|
@ -31,4 +31,8 @@ private:
|
||||
// Projectile Movement Component for Shooting
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Component", meta=(AllowPrivateAccess="true"))
|
||||
class UProjectileMovementComponent* ProjectileMovement;
|
||||
|
||||
// Function for Hit Event
|
||||
UFUNCTION()
|
||||
void OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit);
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user