Hey,
While reading the second paragraph of the components documentation, i got quite confused. I feel it is slightly misleading, that or i just don’t understand whats going on.
“Contrary to the default behavior of sub-objects in general, Components created as sub-objects within an Actor are instanced, meaning each Actor instance of a particular class gets its own unique instances of the Components.”
Here if you don’t know about the instanced keyword you might think that that sub-objects, while the game is running, all point to the same object, i don’t know this might be strange but this confused the hell out of me when reading this.
From my understanding like any c++ class, properties are all new and separate instances when you instance the class. (Edit: if not a pointer of course, sub-objects are used as pointers so it could well be that we have only one instance per class)
The way I understand this now is that, when looking at the class in editor or placing in world, each of these separate base instances get a separate instance that you can edit, instead of all these instances starting with the same defaults.
Now I am using instanced a lot here and it seems that I use it for things that should be described with another word.
I feel the second part just makes the misunderstanding worse for me:
“A simple way to visualize this is to imagine the vehicle described above. A Car class might use Components to represent the wheels of the car. Four Wheel Components would be created as sub-objects in the default properties of the class and assigned to a Wheels] array. When a new Car instance is created, new instances of the wheel Components are created specifically for that Car. If this were not the case, when one Car in the world moved, the wheels of all Cars would turn; which is clearly not the desired behavior. Instancing of Components by default simplifies the process of quickly adding unique sub-objects to Actors.”
This gives me the impression that if I create a UObject with with a variable B and assign 4 of them as sub-objects of an actor. When modifying variable B on one actor all other instances of this actor will have this the change to B reflected to them because there is only one version of B all pointed to by the separate actor instances
Anyway I wonder if anyone else had this same confusion? Is it just me? I’m feeling quite stupid at the moment, wondering if i’m just missing some huge part of the puzzle.
What I think is going on is a misunderstanding on the vocabulary and this might be emphasized by the fact that we don’t have much documentation on CDO’s, what it really means to place an actor in a world window etc. That and the word instanced which is used, I think, here with a different context to which most programmers are used to.