What is more proper to use? (component or actor or uobject)

I have a SpellCasterComponent which is owned by a Controller.

Within this component I want to add another object to handle the SpellBook (which is a container of spells with some functions to load, add, delete, etc… that will need to be replicated).

What the SpellBook should be? a Component? an UObject? an Actor?

It is nothing more than a Container of spells, so I would choose UObject but maybe an Actor is required in order to replicate on the server.

If you want the spell book to be replicated, then you can’t really use a UObject unless you’re happy to replicate its variable through an AActor. You could make an UActorComponent and then replicate it through the owning AActor. UActorComponent or UObject will be more light weight than an AActor however.

On the other hand, if spellbook is a list of spells and this list doesn’t change, then you don’t need to replicate it. It could be a simple UObject that will have the same content on server and all clients, and reference to a spell will resolve to the same one, you could replicate this reference. (eg spellId, that is accessed via Spellbook->GetSpellById(spellId))

That’s definitely a great idea! You’d have to be a little careful about creation of the spells though I think.

Problem is that spells can be crafted so I can’t really have an unique identifier for each spell.

For the moment I made the Spellbook an Actor, and spawn it in SpellCasterComponent BeginPlay method,
but this is bothering me since the more appropiate place to spawn it should be in the constructor but I can’t spawn actors within a constructor (World is null)

If you need it to be actor, there is no problem spawning it in BeginPlay (or even inside Tick, when it’s needed, if it is not spawned already).

You could change it into Component, so you can create it in constructor.

There is no real ‘correct’ way of doing it; it all depends how you need it. Actors can have their components. Components can’t, but both actors and components can have their own replication rules. Raw UObjects can only be replicated via its parent (component or actor). All approaches are ready to be used whichever way suits!

what do you mean? I can’t have a component attached to another component?

I think that this information is held by the owning actor (sub-attachment of components to each other); but I’m not 100% sure.

Eg, in Actor’s constructor (that owns both components), you’d attach one component to another via



FollowCamera->AttachTo(CameraBoom)


This is totally unclear to me -.-

Still I think I’m gonna stay with simple Actor, it seems that it would be the less problematic choice.