after reading through again sorry for initial confusion, the previous answers are about “exposing UPROPERTY to have it be viewable/Editable in details windows”
I am not sure what an appropriate title, but the concern as stated in the paragraph.
my past experience with Unity was 10 years ago (when they went to subscription instead of lifetime license), but from my memory technically everything that inherits from GameObject
would be equivalent to an Unreal USceneComponent
the UPROPERTY governs how it can be shown in the Details window, and in the blueprint graph. while the class type and UCLASS()
macros govern how it can be interacted.
to have it be added to a blueprint at all needs to have the UCLASS()
specifiers of BlueprintType
(this is true for structs as well to have those show up) and maybe meta=(BlueprintSpawnableComponent)
. for a UActorComponent
and anything that inherits from them that are added through the Add C++ dialog window ‘should’ have these already.
for UActorComponent
vs USceneComponent
this comes down to the simple question of “does it need to have a transform?” or better put “does the component need to physically or logically need to exist in space?”
where a USceneComponent
inherits from UActorComponent
at the base class level the only difference is that USceneComponent
has a transform, and is added to the hierarchy directly, while UActorComponent
is just there with the AActor
.
some example of USceneComponents:
UStaticMeshComponent
and by inheritance USkeletalMeshComponent
these are the most tangible example where everything from the Cube or plane you place for a floor or a wall to the body of your actor. anything that has physical form in your level is in most cases going to be one of these. or a UNiagaraSystem
but that will still have a USceneComponent because…
AActor->RootComponent*
every actor that is created will have a USceneComponent
as the root component just so the Actor has a transform, this also enables us to do things like Attach actors to other Actors by virtue of thinking of an AActor
as a USceneComponent
UActorComponents
on the other hand are more abstract things like the
- Movement Component it doesn’t need to have physical form, it just needs to know about the transform, but doesn’t need one itself.
some other don’t have too many direct examples in the engine, but some examples that could work:
- character inventory: the inventory doesn’t need to exist in physical space, or have the inventory objects attached to it, it just needs to hold the data for those inventory items in some way.
- character stats: I like to break these out of the ACharacter derived class so that I can give them to
APawn
or even make it so that a wall has health points if I need, and instead of casting to a class derived from AActor/APawn/ACharacter which can reduce modular design, and introduce memory overhead I can see if the Actor has a Component and just talk to that.
the selection of UActorComponent
or USceneComponent
only has implications on where in the hierarchy they appear (USceneComponents
are in the hierarchical chain, while UActorComponents
are listed bellow a horizontal bar after all the USceneComponents
) and whether or not the object “needs a transform” because if everything has a transform that just adds to computational overhead to maintain the offsets.
for anything beyond this deep dive into the differences, or the previous about what to put in a UPROPERTY to make a member variable accessible/visible will need fallow up to the question.