I’m currently making multiple actor components and attaching them to my Character to handle some of the basic features and anothers very specific.
I’d like to know if this is a good practice instead of making all the logic (Special Movement, Radar, Fire, Targeting, …) inside the Character BP.
I’d, also, like to know if attaching too many actor components to my class could be expensive for my game during runtime - one thing that I’ve noticed is that the BP takes a longer time to compile or save.
I’ve been searching for someone that has already asked something similar with no success, so I decided to open this thread for discussion.
I assume the reason your BP takes longer to compile is because you have dependencies between your components. For example component A references component B, therefore when compiling your Character it has to first compile its component A that has to compile component B. Worst case scenario is you have circular dependencies, component A referencing component B referencing component C referencing component A. It should not break anything but might takes longer to compile and procc some crash / fail save from time to time.
Shouldn’t be expansive by itself as a method to my knowledge.
Is it a good practice? I don’t see any reason to do it the way you’re doing it but also don’t see why it wouldn’t work or would be particularly expansive. At least I don’t see any reason in your post, but I don’t know your mechanics so it might be a good way to go.
The way I’m doing the component is to, basically, reuse it to another actors from different inheritances. The Targeting, for instance, could be used for vehicles(Pawn) and Characters, and so on…
Thanks for the reply
I must say, what you said makes total sense for me, but as I don’t have a deeper knowledge on how the Blueprints compile it’s dependencies this still foggy to me. Maybe a detailed documentation about the BP Compiling should clarify it.
I assume that an actor component could be classified as reusable code, so, from that, should be a good practice.
The more your Blueprint grows the longer time it will take to compile. There isn’t much a way to prevent that. Yun-Kun already said what might be true. Not long ago system was not making the compiling global. So you had to get in each component and press compile. Now system does this automaticaly to make sure dependancies work correct which causes it to take longer to compile.
My humble suggestion is using chilld blueprints as much as possible. Currently my character core system in my template takes around 2.5 seconds to compile, while a child that is almost empty is literally instant. Ofcourse child blueprint compile will take longer the more I add in, but at least I don’t waste time compiling the entire core of it that is working behind.
The child is, indeed, one of the best practices for performance and compiling time.
Well, as of now, there’s no objection for attaching multiple actor components, so I’m going to take for granted this is not a bad practice (or at least until someone come here bring new info :)).
Forgot to mention that these actor components are not attached at runtime, otherwise it would be really expensive to create an actor component during runtime, I guess.