Subcomponents for logic?
I have migrated over here from the CryEngine and am having a little trouble with UE4s class templates. I am currently building a character properties system that is split into different subsystems. So for example there is a system that manages health and a different system that handles a characters movement setup. The idea behind this setup is that you can combine different templates for the different systems into different characters. I had already programmed this for CryEngine and it worked. As I am currently migrating this into UE4 I ran into a problem with the UE4 classes. To enable reflection and blueprint setup, which seems to be key in UE4, my classes need to be subclasses of the UE class templates. I read the overview for the classes and decided to let my classes inherit from UActorComponent as my system would be a subobject of an Actor and it should be tickable. That seemed to work for a single component. But apparently ActorComponents can't be subobjects of ActorComponents, which admiditly makes sense but is also somewhat problematic as I now don't know from what class to inherit my classes...
To the technical part:
I want to build the following hierachy: Actor->HealthStats->Individual health components (Array)
Here the class HealthStats:
Here is the code for UHealthComponent:
A few last things to note:
So I hope this gives you enough information to be able to help me.
asked Jun 22 '14 at 02:35 PM in C++ Programming
Main question is why would you want to make nested actor components ? It doesn't bring any benefits expect more complicated design.
What do you want to do, is to create AttributeComponent (or something like that), which will be simply attached to actor.
AttributeComponent will contain any attributes you want as UPROPERTY(), and any function helpers you may need to modify those attributes.
Also remember to override OnRegister(), as this is the place where you want to register all changes to your attributes if you have more complex setup like one attribute calculated from another.
You might also want to create UBlueprintFunctionLibrary with static functions which will be helping to work with your attributes.
If you want to take quick look at what I mean you can look at engine source for AbilitySystem module or on my Action RPG sample (in the works): https://github.com/iniside/ActionRPGGame/tree/master/Source/ActionRPGGame/Componenets For AttributeComponenets. I have finished implementing this (it boiled down to more pressing issues), but you can see beginings of the system. It also uses reflection system, to take arbitary properties out of class by specified their name.
answered Jun 22 '14 at 03:02 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here