Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Extending AActor shows neither components nor properties

Hi everyone,

I'm currently trying to implement a custom actor class with UE4.20, but I'm having quite a few issues with that. Beside the tutorials and examples often missing includes or just telling "hey, just use this code [...]" without telling where the code is intended to be called so far nothing seems to be working as expected.

For this concrete example I'm using https://docs.unrealengine.com/en-us/Programming/Tutorials/Components/1 and https://gist.github.com/Chaosed0/4a378922ede069bb20d6 as references. (I read through a lot of related articles on google about this, but I'm not going to list them all here)

So my class currently looks like this:


 // Fill out your copyright notice in the Description page of Project Settings.
 #pragma once
 #include "CoreMinimal.h"
 #include "GameFramework/Actor.h"
 #include "Engine/StaticMesh.h"
 #include "Engine/Classes/Components/SphereComponent.h"
 #include "Engine/Classes/Components/StaticMeshComponent.h"
 #include "ConstructorHelpers.h"
 #include "OrbActor.generated.h"
 class SPACEEXPLORER_API AOrbActor : public AActor
     // Sets default values for this actor's properties
     AOrbActor(const FObjectInitializer& ObjectInitializer);
     /** Radius of the orb. */
     float OrbRadius;
     /** Physics component of the orb. */
     class USphereComponent* OrbPhysics;
     /** Static mesh component of the orb. */
     class UStaticMeshComponent* OrbMesh;
     // Called when the game starts or when spawned
     virtual void BeginPlay() override;
     // Called every frame
     virtual void Tick(float DeltaTime) override;


 // Fill out your copyright notice in the Description page of Project Settings.
 #include "OrbActor.h"
 // Sets default values
 AOrbActor::AOrbActor(const FObjectInitializer& ObjectInitializer)
     // Default property values
     OrbRadius = 1.0f;
      // Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
     PrimaryActorTick.bCanEverTick = true;
     // Create physics component
     OrbPhysics = CreateDefaultSubobject<USphereComponent>(TEXT("RootComponent"));
     RootComponent = OrbPhysics;
     // Create static mesh component
     OrbMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("VisualRepresentation"));
     static ConstructorHelpers::FObjectFinder<UStaticMesh> SphereVisualAsset(TEXT("/Game/StarterContent/Shapes/Shape_Sphere.Shape_Sphere"));
     if (SphereVisualAsset.Succeeded())
         OrbMesh->SetRelativeLocation(FVector(0.0f, 0.0f, 0.0f));
 // Called when the game starts or when spawned
 void AOrbActor::BeginPlay()
 // Called every frame
 void AOrbActor::Tick(float DeltaTime)

The code as shown compiles fine (tried both starting the compile in Visual Studio or the UE-Editor), but as a result when adding the actor it will neither show the sub components, neither any of the defined UPROPERTY fields. What am I getting wrong here? Any help would be greatly appreciated.

Edit: Forgot to attach the screenshot of the result: alt text

Product Version: UE 4.20
screen1.png (64.4 kB)
more ▼

asked Jul 25 '18 at 06:25 PM in C++ Programming

avatar image

1 1

avatar image Shadowriver Jul 25 '18 at 11:39 PM

Check the logs in Window->Developer Tools->Output Log (and keep it open because all runtime errors are going to show there, it also printed in Saved/Logs of you project directory) and see if you not have any messages, actor definitely should output info that RootComponent was not set.

If you hot reloading adding things to class can be really messy sometimes, if you see this kind of strange behaviors, close editor compile in VS and open editor back.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question