Created
January 29, 2017 18:07
-
-
Save HappyZombies/b6a6007bf6051a19160223b0ff0ecf3d to your computer and use it in GitHub Desktop.
Unreal Engine simple Overlap sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Fill out your copyright notice in the Description page of Project Settings. | |
#include "Jack.h" | |
#include "Pad.h" | |
// Sets default values | |
APad::APad() | |
{ | |
// 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; | |
padRoot = CreateDefaultSubobject<USceneComponent>(TEXT("PickUpRoot")); | |
RootComponent = padRoot; | |
myMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("myMesh")); | |
myMesh->AttachToComponent(padRoot, FAttachmentTransformRules::SnapToTargetNotIncludingScale); | |
padBox = CreateDefaultSubobject<UBoxComponent>(TEXT("PickUpBox")); | |
padBox->SetWorldScale3D(FVector(1.0f, 1.0f, 1.0f)); | |
padBox->bGenerateOverlapEvents = true; | |
padBox->OnComponentBeginOverlap.AddDynamic(this, &APad::onPlayerEnterPadBox); | |
padBox->AttachToComponent(padRoot, FAttachmentTransformRules::SnapToTargetNotIncludingScale); | |
} | |
// Called when the game starts or when spawned | |
void APad::BeginPlay() | |
{ | |
} | |
// Called every frame | |
void APad::Tick( float DeltaTime ) | |
{ | |
Super::Tick( DeltaTime ); | |
} | |
void APad::onPlayerEnterPadBox(UPrimitiveComponent* OverlappedComp, AActor* otherActor, UPrimitiveComponent* otherComp, int32 otherBodyIndex, bool bFromSweep, const FHitResult& sweepResult) | |
{ | |
FString name = OverlappedComp->GetName(); | |
uint32 id = OverlappedComp->GetUniqueID(); | |
UE_LOG(LogTemp, Warning, TEXT("%d is the id for the box you entered."), id); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment