Hi All users.
I Have a New Actor in “Unreal Engine 4.5.1” But This Actor Not Working.
Header File TriggerTest.h
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "GameFramework/Actor.h"
#include "TriggerTest.generated.h"
/**
*
*/
UCLASS()
class ARMITA_API ATriggerTest : public AActor
{
GENERATED_UCLASS_BODY()
TSubobjectPtr<UBoxComponent>Box;
TSubobjectPtr<UPointLightComponent>Light;
UFUNCTION()
void Debug(FString Massage);
UFUNCTION()
void OnBeginOverlap(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool FromSweep, const FHitResult& SweepResult);
UFUNCTION()
void OnEndOverlap(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool FromSweep, const FHitResult& SweepResult);
};
C++ File TriggerTest.cpp
// Fill out your copyright notice in the Description page of Project Settings.
#include "Armita.h"
#include "TriggerTest.h"
ATriggerTest::ATriggerTest(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP)
{
Box = PCIP.CreateDefaultSubobject<UBoxComponent>(this, TEXT("Box"));
Light = PCIP.CreateDefaultSubobject<UPointLightComponent>(this, TEXT("Light"));
Box->bGenerateOverlapEvents = true;
Box->SetRelativeScale3D(FVector(2,2,5));
RootComponent = Box;
Light->Intensity = 1000;
Light->SetLightColor(FColor::Red);
Light->AttachParent = RootComponent;
Box->OnComponentBeginOverlap.AddDynamic(this, &ATriggerTest::OnBeginOverlap);
Box->OnComponentEndOverlap.AddDynamic(this, &ATriggerTest::OnEndOverlap);
}
void ATriggerTest::OnBeginOverlap(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool FromSweep, const FHitResult& SweepResult)
{
Light->SetLightColor(FColor::Green);
Debug("Open");
}
void ATriggerTest::OnEndOverlap(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool FromSweep, const FHitResult& SweepResult)
{
Light->SetLightColor(FColor::Red);
Debug("Close");
}
void ATriggerTest::Debug(FString Massage)
{
/*if (UEngine)
{
UEngine::AddOnScreenDebugMassage(-1, 1, FColor::Red, Massage);
}*/
}
Unreal Engine 4.5.1 ERROR