How to make a custom Actor visible in Editor

I think I don’t get some fundamentals. I’m sorry for a noob-question but cannot find it in the docs. How does it happen that an editor renders dummy white sphere for an empty blueprint actor? How can I achieve that for my custom C++ actor?

When I create it like this:



#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "DumbPathNode.generated.h"

UCLASS()
class PROTOTYPE_API ADumbPathNode : public AActor
{
    GENERATED_BODY()

public:    
    ADumbPathNode();

    UPROPERTY(EditAnywhere)
    ADumbPathNode* NextNode;

protected:
    virtual void BeginPlay() override;
};




#include "DumbPathNode.h"

ADumbPathNode::ADumbPathNode()
{
}

void ADumbPathNode::BeginPlay()
{
    Super::BeginPlay();
}


It is not visible when I drag it into level in an editor. Blueprint inherited from this class is visible and rendered in editor as a white sphere. Why?

Hi SirMike,

You just need to add a USceneComponent:

Header:
#pragma once #include “CoreMinimal.h” #include “GameFramework/Actor.h” #include “DumbPathNode.generated.h” UCLASS() class PROTOTYPE_API ADumbPathNode : public AActor { GENERATED_BODY() public: ADumbPathNode(); UPROPERTY(EditAnywhere) ADumbPathNode* NextNode; protected: virtual void BeginPlay() override; UPROPERTY(EditAnywhere) USceneComponent SceneComponent;* };
Code:
#include “DumbPathNode.h” ADumbPathNode::ADumbPathNode() { this->SceneComponent = CreateDefaultSubobject<USceneComponent>(TEXT(“SceneComponent”)); this->RootComponent = SceneComponent; } void ADumbPathNode::BeginPlay() { Super::BeginPlay(); }
Try adding the emboldened lines to your code, then drag your C++ script into the scene and it should work.

Cheers,

BrujoCorvino

Hi BrujoCorvino, thanks for an answer. Unfortunately it does not work either. It was the first idea that came to my mind. Actor is still invisible in editor :confused:

I think I got this!


SceneComponent->bVisualizeComponent = true;

At least in UE_4.19 which I use. Thanks for the hint.

Glad to hear it’s working SirMike. Good luck from another C++ noob :slight_smile: