Hello, i’m trying to set up a Blueprint native event, the problem i always have this warning at compiling:
warning C4996: Function NPC::Prox needs native implementation by virtual void Prox_Implementation(AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult) due to its properties. Currently Prox_Implementation declaration is autogenerated by UHT. Since next release you’ll have to provide declaration on your own. Please update your code before upgrading to the next release, otherwise your project will no longer compile. g:\u4\projects\tutorialproject\source\tutorialproject\NPC.h(11)( TutorialProject
As i know, i should create a class named Prox_Implementation as the warning and the guide i’m following says, but i just don’t get it working, both source codes are there:
By the way, the HUD class is called AMyActor, it’s named like this just because my mouse accidentally did double click and for some reason just named it as the last item i selected before selecting the HUD class on the parent class
NPC.H
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "GameFramework/Character.h"
#include "NPC.generated.h"
UCLASS()
class TUTORIALPROJECT_API ANPC : public ACharacter
{
GENERATED_BODY()
// Sets default values for this character's properties
ANPC(const FObjectInitializer& ObjectInitializer);
// Called when the game starts or when spawned
virtual void BeginPlay() override;
// Called every frame
virtual void Tick( float DeltaSeconds ) override;
// Called to bind functionality to input
virtual void SetupPlayerInputComponent(class UInputComponent* InputComponent) override;
public:
UPROPERTY(EditAnywhere, BluePrintReadWrite, Category = NPCMessage)
FString NpcMessage;
UPROPERTY(VisibleAnywhere, BluePrintReadOnly, Category = Collision)
USphereComponent* ProxSphere;
UFUNCTION(BlueprintNativeEvent, Category = "Collision")
void Prox(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
};
NPC.CPP
// Fill out your copyright notice in the Description page of Project Settings.
#include "TutorialProject.h"
#include "NPC.h"
#include "Avatar.h"
#include "MyActor.h"
ANPC::ANPC(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
{
PrimaryActorTick.bCanEverTick = true;
ProxSphere = ObjectInitializer.CreateDefaultSubobject<USphereComponent>(this, TEXT("Proximity Sphere"));
ProxSphere->AttachTo(RootComponent);
ProxSphere->SetSphereRadius(32.0f);
ProxSphere->OnComponentBeginOverlap.AddDynamic(this, &ANPC::Prox);
NpcMessage = "Ola k ase";
}
// Sets default values
/*ANPC::ANPC()
{
// Set this character to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
}*/
// Called when the game starts or when spawned
void ANPC::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void ANPC::Tick( float DeltaTime )
{
Super::Tick( DeltaTime );
}
// Called to bind functionality to input
void ANPC::SetupPlayerInputComponent(class UInputComponent* InputComponent)
{
Super::SetupPlayerInputComponent(InputComponent);
}
void ANPC::Prox_Implementation(AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult)
{
if (Cast<AAvatar>(OtherActor) == nullptr)
{
return;
}
APlayerController* PController = GetWorld()->GetFirstPlayerController();
if (PController)
{
AMyActor * hud = Cast<AMyActor>(PController->GetHUD());
hud->addMessage(Message(NpcMessage, 5.f, FColor::White));
}
}