I’m trying to create a character with one or multiple box components added to it.
There is a default one where there is one such box with an extent of (100,100,100).
Creating this character and placing it in the level works flawlessly.
The gist of it is, that it should be possible to change the extent of the box in the details panel of a placed instance of the actor.
For some reason it seems that only variables defined in the base-class of the blueprint (in this case character.h) are visible and changeable in the details panel (variables from blueprint-added components are not available).
Am I doing something wrong or is this just the way it works (or rather doesn’t work)?
According to my understanding of blueprint, the character blueprint extending the character.h class is itself (some kind of) a generated c++ class.
Placing a blueprint inside of a level is like creating an instance of this class, where the variables can then be changed differently for each instance.
I’ve tested, that It is possible to access and change the variables using a blueprint script but it is rather ugly as the change to the extent is not directly visible.
So how come those variables are not visible in the details panel even though they exist and can be accessed?
Thanks in advance!
Seems like it is working. Thank you very much!
What I still don’t understand is, why those values are not displayed and changeable in the first place? Is there some engine reason so it would be on purpose?
You can set the box’s scale in construction script and then make that scale variable Editable. That way you can change it via details panel inside the editor viewport.
I dont know the technical reason behind it but in my opinion it would just cause a mess in Details panel when you have a bunch of components in the BP.
I’m using your proposed solution now (thanks again), and though it works it is not really an ideal solution for my problem.
I would like to create a custom component (in c++) containing one or a few variables (for example an int). I would then like to add this component to any actor-blueprint and be able to change these variables in the details panel without having to add all these construction scripts and variables manually for each blueprint the component is used in.
Any idea if this is somehow possible?
I know that question is old, but that might help someone.
To make an actor’s CPP component editable in blueprints in Unreal Engine 4:
- The key is to use “VisibleAnywhere”, and optionally “BlueprintReadOnly” in the UProperty meta so the editor displays them correctly. (IE: the movement component in the Character class)
- This way you can have both a default object configuration AND editor customization via blueprints.
- To add components at runtime, see this discussion.
Example code for a box component, in your actor class header:
In your actor class constructor:
MyBox = CreateDefaultSubobject<UBoxComponent>(TEXT("MyBox"));