Variables from instanced component are not shown in the details window

Greetings,

so I have a component I created in c++ derived from USphereComponent and in it some variables with UPROPERTY()
I added this component into a blueprint actor derived from the basic Actor.

In the blueprint editor, I can see the variables of my component when I click on the component. I can see “Sphere Radius” as well.

But, when I place this actor in the level, I can no longer see all the component’s variables, including the “Sphere Radius”.

The only way to make this work is that I derive a custom actor that has this component as a default object, but I would prefer not to do that for every type of actors we are going to have, I would rather the component I made can be added to any actor and edited through the details panel.

Is there some flags of some sort I can try ?

Thanks.

Unfortunately, an inherent limitation of blueprint actors is that components added through blueprint will not be visible outside of the Components tab. You can create blueprint variables and forward them to your component in the construction script. Other than that, the only solution is a native base class.

How to Expose Variables Of an Instanced C++ Actor Component

Dear Polytopey,

I wrote my own C++ AI navigation system from scratch which uses actor components to store nav data.

I routinely place actors into the world and then edit the values of the component, on a per-instance basis, to have per-instanced nav-generation control.

So just to be clear, I am indeed talking about dragging actors that have your custom component, from C++, into the level and then editing the component’s values per-instance.

mentions the solution I am showing below, where you use a C++ base class for your actor, which houses your custom component.

If you don’t mind using a C++ Base class, an AActor-deriving class that stores your custom actor component, then the code I show below will great for you!

I encountered the issue of using C++ components with BP Actor classes while working on a custom component for Solus, and I am pretty sure you really do need a C++ AActor base class to store the component.

I found per-instance variable control to be essential for my own workflow, you might consider just making the necessary AActor-deriving C++ base classes to support the ultimate speedy workflow that your level designers and you will want in the Editor :slight_smile:


**C++ Code**

Here's my relevant C++ code!

The C++ Actor Class that uses the component



UPROPERTY(VisibleAnywhere, Category=JoySMAHighest,meta=(ExposeFunctionCategories="JoyNav", AllowPrivateAccess = "true"))
UJoyNavComp* JoyNavComp;

_



**The C++ Component**



```


//Choosing a class group and making it BlueprintSpawnableComponent
UCLASS(ClassGroup=JoyMech, meta=(BlueprintSpawnableComponent))
class UJoyNavComp : public UActorComponent
{ 
	GENERATED_BODY()
public: 
	UJoyNavComp(const FObjectInitializer& ObjectInitializer);
	
	//UPROPERTY(EditAnywhere, BlueprintReadWrite,Category="JoyNav")
	//FString CustomNavGroup;
	  
	/** Density Core Value, the smaller the more dense, density = 360/JoyNavDensity */
	UPROPERTY(EditAnywhere, BlueprintReadWrite,Category="JoyNav")
	float JoyNavDensity;
	
	/** Draw Units! */
	UPROPERTY(EditAnywhere, BlueprintReadWrite,Category="JoyNav")
	bool DoDrawUnits;
	
	UPROPERTY(EditAnywhere, BlueprintReadWrite,Category="JoyNav")
	bool DoDrawJoyNavDisplayInfo;
	 
	/** Each radius gets its own layers of units! */
	UPROPERTY(EditAnywhere, BlueprintReadWrite,Category="JoyNav")
	TArray<int32> RadiusLevels;
	
	/** Trim out units that are closer than Radius * TrimPercent */
	UPROPERTY(EditAnywhere, BlueprintReadWrite,Category="JoyNav")
	float TrimPercent;
	
//.. etc


```



With this setup I can load the editor, make a BP of my C++ actor that uses the component, and then drag it into the world, and edit the component values directly, per-instance.

I can even add to the dynamic array on a per-instance basis, it’s really neat!

Thanks Epic!


**Picture**

Notice the C++ variable names above of the component match what I can edit per instance in the level!

![16b5973d284e272195a1c0ed026f1b1c98d6facb.jpeg|1192x684](upload://3eTyLHbITjwk8gw16r4I9tZsBnl.jpeg)


Enjoy!

Rama
1 Like

cmartel & Rama, thank you for the quick and very detailed reply :slight_smile:

Ok, I know about using the custom c++ actor, I was wondering if there was a way to using just blueprint actor, but I guess not, so we’re gonna have to go with custom c++ actors.

Thank you again!

link to wiki