Advertisement
orfeasel

Hit register and implementations

Dec 27th, 2015
9,099
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.84 KB | None | 0 0
  1. AFallingActor::AFallingActor()
  2. {
  3.     // Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
  4.     PrimaryActorTick.bCanEverTick = true;
  5.  
  6.     //Initialize a StaticMeshComponent
  7.     SM = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("CubeSM"));
  8.  
  9.     //Enable physics so the cube will fall
  10.     SM->SetSimulatePhysics(true);
  11.  
  12.     //You only need to register the OnHit function
  13.     SM->OnComponentHit.AddDynamic(this, &AFallingActor::OnHit);
  14. }
  15.  
  16. void AFallingActor::OnHit(AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit)
  17. {
  18.     GLog->Log(*OtherActor->GetName());
  19. }
  20.  
  21. void AFallingActor::ReceiveHit(UPrimitiveComponent* MyComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit)
  22. {
  23.     GLog->Log(*OtherActor->GetName());
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement