Download

Need help with some code!

Hi, I’m kinda new to all this and I need some help with the coding. I’m reading and following a book by PaktPublishing and I ran into trouble while following along. I have the following code:

UCLASS()
class GOLDENEGG_API ANPC : public ACharacter
{
GENERATED_UCLASS_BODY()
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category =
Collision)
TSubobjectPtr<class USphereComponent> ProxSphere;
// This is the NPC’s message that he has to tell us.
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category =
NPCMessage)
FString NpcMessage;
// When you create a blueprint from this class, you want to be
// able to edit that message in blueprints,
// that’s why we have the EditAnywhere and BlueprintReadWrite
// properties.
}

I copied and pasted the code and changed the “GENERATED_UCLASS_BODY()” part with just “GENERATED_BODY()” since I’m using UE4.8.3 (this was actually there I just copied whats next) and I also changed the “ACharacter” with “ANPCCharacter” since my Character class is called “NPCCharacter”.

So with whats above as example I have the following code that doesn’t compile:

UCLASS()
class GOLDENEGG_API ANPC : public ANPCCharacter
{
GENERATED_BODY()
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Collision)
TSubobjectPtr<class USphereComponent> ProxSphere;
// This is the NPC’s message that he has to tell us.
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = NPCMessage)
FString NpcMessage;
};

Anyway so when I try to compile I get these errors:

  1. error code: OtherCompilationError (5)
  2. error MSB3073: The command ““C:\Program Files\Epic Games\4.8\Engine\Build\BatchFiles\Build.bat”
    GoldenEggEditor Win64 Development “C:\Users&lt;user>\Documents\Unreal Projects\GoldenEgg\GoldenEgg.uproject” -
    rocket” exited with code -1.

When I delete the contents of the under “GENERATED_BODY()” all compiles well.
Please help!!!
Thanks in advance!