Dear UE4 Community,
I’m trying to convert a header and cpp file syntax from an older version to 4.9, Can you please help me? Thanks. Iknow that USphereComponent is now declared as a pointer, but can’t figure out the rest, thanks again.
Header File
UCLASS()
class GOLDENEGG_API ANPC : public ACharacter
{
GENERATED_UCLASS_BODY()
// This is the NPC's message that he has to tell us.
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category =
NPCMessage)
FString NpcMessage;
// The sphere that the player can collide with to get item
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category =
Collision)
TSubobjectPtr<class USphereComponent> ProxSphere;
// The corresponding body of this function is
// ANPC::Prox_Implementation, __not__ ANPC::Prox()!
// This is a bit weird and not what you'd expect,
// but it happens because this is a BlueprintNativeEvent
UFUNCTION(BlueprintNativeEvent, Category = "Collision")
void Prox( AActor* OtherActor, UPrimitiveComponent* OtherComp,
int32 OtherBodyIndex, bool bFromSweep, const FHitResult &
SweepResult );
};
CPP FILE
ANPC::ANPC(const class FPostConstructInitializeProperties& PCIP) :
Super(PCIP)
{
ProxSphere = PCIP.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
}