I have struggling a while now to get grip on the concept of actors and components, how they differ and how the are connected. Unfortunately I haven’t found any good place where this whole concept is described.
This is what i have found so far:
On the unreal achitecture page in the manual, the relation between actors and components are described: “Take a car as an example. The car as a whole is an Actor, whereas the parts of the car, like the wheels and doors, would all be Components of that Actor.”
Ok, this sounds reasonable, but then the components have the the undocumented function: SetChildActorClass. This indicates that Components can have Actors as children, although the above mental model was indicating the opposite.
Further confusing is that classes seams to exist in both an actor and a component variant like, UStaticMesh and UStaticMeshComponent.
The documentation I found about components didn’t tell much about the component class or how to create a component. (It mainly tells that the components has to be registered, without telling where or when this has to be done.)
What I am trying to do is this:
Implement a city-object that can be dragged into a level. This city-object shall create a city by creating a bunch of block-objects at suitable positions. The block-object should then be responsible for drawing the actual building(s) on that block.
(During the initial experiments I am satisfied if the block-object just can draw a cube with the size of the block, simulating a house.)
So far i have tried to make both the the city-object and the block-object as actors. But when I look at the code required, this doesn’t feel like the right way.
And spawning actors is not an option in this case, since spawning does not occur until the game starts. I would like see the result from the city-object directly in the level editor so that I add further actors at suitable places.
Would it be better to make the block-object as a component instead of an actor?
If so, will it be possible for the block-object to have child objects like house-objects, and should this house-objects then be components or actors?
I could use a little help here or some good resources where actors and components are explained a bit more in detail?
Are there any examples including creation of a user-defined component?
Any help that can cast some light on the issue would be very much appreciated…