Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- AFallingActor::AFallingActor()
- {
- // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
- PrimaryActorTick.bCanEverTick = true;
- //Initialize a StaticMeshComponent
- SM = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("CubeSM"));
- //Enable physics so the cube will fall
- SM->SetSimulatePhysics(true);
- //You only need to register the OnHit function
- SM->OnComponentHit.AddDynamic(this, &AFallingActor::OnHit);
- }
- void AFallingActor::OnHit(AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit)
- {
- GLog->Log(*OtherActor->GetName());
- }
- void AFallingActor::ReceiveHit(UPrimitiveComponent* MyComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit)
- {
- GLog->Log(*OtherActor->GetName());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement