Question about Scene Components and Upropertys

I was attempting to build a very basic tile generator for a project. My idea was to have each tile (for now the default scene floor) have sockets (for now being represented as basic USceneComponents) and using the socket transforms to spawn a tile adjacent to another tile and offset using the scene component transform. I set up my variables in my header, and intended to use a

TArray<USceneComponent*> AttachPoints;

to do so, and search for appropriate components in the Tile constructor and populate the TArray with them. This seemed like a good idea at the time, as I could specify where I wanted the sockets to be in blueprints while the parent C++ code sets it up for me. However, I can only see the TArray in the basic blueprint editor and it goes away when the “Full Blueprint Editor” is opened. I made sure I had the correct UPROPERTY(EditAnywhere) macro, and other variables such as float values and Static Mesh pointers show in the Class Defaults Detail panel with no hassle.

I’ve tried restarting Unreal and deleting the immediate folder and refreshing my vs project in case it was an edge case bug, but I’m starting to think there is something I am missing about how to use SceneComponents.

image

Please let me know what part about scene component/ C++ and Blueprint interaction I am misunderstanding.

Sorry but what exactly is the question?

I started this as one question but while working on it it turned into multiple.

First, why don’t TArray<USceneComponent*> show up in the blueprint editor

Second, if I am trying to make a blueprint with components I want to be present in all children of it (say 4 USceneComponents) but I want to specify something different about them like their transform, how would I go about doing that?

It does, it’s in your screenshot. You can’t edit it though as you marked it VisibleAnywhere.

Could you give an example?

The one in my screenshot is not the one that isn’t showing up, I forgot to remove the TEST category one before posting, the Attatchpoints2 is what is failing to show.

As for an example, If I have a default C++ class that has a list of USceneComponents, I want to be able to have as many of them as I want, and I specify where they are in the Blueprint child class. I’ll know that I want to use those scene component transforms in my code, but I want to be able to visually decide where their transforms are in the blueprint child class.

Does that help?

Sorry I didn’t notice you had two arrays in that screenshot.

For some reason the array only appears in the minimal view and not the full blueprint editor, that’s probably a bug.
You can sort of get what you’re after by using the Instanced specifier

UPROPERTY(Instanced, EditDefaultsOnly)
TArray<USceneComponent*> Test;

However you can’t select Scene Component. So you’ll have to use Billboard or Arrow (or create your own).

I tried using the instanced specifier, and creating my own class based on USceneComponent, but it still only shows in the minimized view and not the full blueprint editor. I tried using arrows as well and they wouldn’t show up either. I’m not sure if it’s a bug, it almost seems like an intentional design pattern, but I’m not sure what it would be.

It’s a bug either way you slice it.

Either this should only be visible on instances or anywhere. The minimal view is just a more compact editor for when there’s only properties on the BP and nothing in the event graph, it shouldn’t effect whether or not a property is visible.

Hmm ok, I tried using a TSet instead and it appears fine, strange bug. I had a follow-up question though, I want to have a Set of Attatchpoints so I made a function that should populate a Set using GetComponents and it is called in the constructor, but the set is always empty.

(in the header)

image

Am I going about this the wrong way? Is this an unnecessary step? My end goal is to have a set of sockets that have enum attributes so that I can decide what tiles to spawn adjacent to other tiles.

I think I’m struggling to understand the workflow for making C++ Actors and Blueprint instances, or the “best practice” / “dos and don’ts” of it.

So there are going to be a variable number of attach points for different derived classes? And when you do call that function?


P.S. I did submit a bug report about that and the bug is that it’s showing up at all for defaults. It should only be viewable on instances.

Thank you for submitting a bug report. This is a known issue that you can track here

Unreal Engine Issues and Bug Tracker (UE-100125).

Please be aware that this issue may not be prioritized or fixed soon.

Variable number of attach points, yes, but they’re all going to be 1 type of derived class, UAttatchPoint, one I wrote that inherits from USceneComponent. I call it in my constructor for the AWaveTile actor, it reaches the function, but never populates the TSet<UAttatchPoint*>

The constructor would be the wrong place to do that as that is for the defaults. Does it work if you move it to BeginPlay?

Edit: It did not work how how I anticipated, which is a bit silly of me, of course it would work when the game was running and I didn’t look there, which ultimately is the most important thing.

So, constructors should be used to set default values, but not populate variables, which I suppose makes sense anyways since I would never need to use a container when the game isn’t running anyways.

Yes, the constructor will run multiple times. One of them being for creating the “class default object” (CDO) which will be used to create the derived blueprint, they are copied from the CDO.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms