I´m Learning C++ in Unreal 4 with a book … and the examples are from Unreal 4.4
I having some problems with the compatibility, many of them was solved from foruns but this one i´m looking solution for hours and i can´t find
Here is the problem !
My code to insert a box colision to say a msg to the player when it´s hit it
.h file
UCLASS()
class GOLDENEGG_API ANPC : public ACharacter
{
GENERATED_BODY()
public:
// Sets default values for this character's properties
ANPC(const FObjectInitializer& ObjectInitializer) : Super(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;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Collision) USphereComponent *ProxSphere;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = NPCMessage) FString NpcMessage;
UFUNCTION(BlueprintNativeEvent, Category = "Collision")
void Prox(AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult);
};
.cpp file
ANPC::ANPC(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
ProxSphere = ObjectInitializer.CreateDefaultSubobject<USphereComponent>(this, TEXT("Proximity Sphere"));
ProxSphere->AttachTo(RootComponent);
ProxSphere->SetSphereRadius(32.f);
// Code to make ANPC::Prox() run when this proximity sphere
// overlaps another actor.
ProxSphere->OnComponentBeginOverlap.AddDynamic( this, &ANPC::Prox);
NpcMessage = "Hi, I'm Owen";
//default message, can be edited // in blueprints
}
// 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)
{
AMyHUD * hud = Cast<AMyHUD>(PController->GetHUD());
hud->addMessage(Message(NpcMessage, 5.f, FColor::White));
}
}
Some one can give a light about what is wrong??