My Player Controller contains a lot of code, and I am looking for a way to organise it. I’ve considered using Actor Components, but this is my first time doing this, so I don’t know if it’s a good idea or if there are better approaches.
generally speaking its a good idea to use ACs to separate logic but, if it works it works, dont change your whole project unless there is some benefit (ie reusing in another project)
This. Actor components are awesome for compartmentalizing logic and tidying up event graphs in something used and edited a lot like player controller or characters. But if something is working as is, don’t reinvent the wheel unless you think it will squeeze out some more performance or will make maintaining it easier in the long run. Like, tonight, I redid the whole mana and spell inventory system for my Metroidvania side project with a spell inventory component. My player has a secondary corruption mechanic that’s derived from mana pool (and essentially acts as a in-world mana bar). Rather than making a component just for that I left the logic in the player char bp event graph, and just bound it to OnManaChanged dispatcher from spell inventory component instead of checking the old mana float on base human class every .5s. Since it only affects player, I didn’t want to put it in spell component used by all npcs and some creatures, and making a whole component for like 10 blueprint nodes would be overkill.
All right, what you’re saying is fine, but that’s not what I’m wondering about. As I mentioned in my question, I’m looking for a way to organise the code, and I’m wondering if actor components could be used for that purpose.
Besides, I don’t like leaving code in a mess. That wouldn’t be a viable solution.
Generally speaking though, I would avoid making components for logic that would only ever be used by the class you’re trying to tidy (unless you want to reuse in another project or something). Likewise for events that interact with an existing child component of class. For highly specific things like those, I would recommend selecting all the nodes in a complex event, rightclick, and hit collapse to function. This will move the selected logic into a new function in the bp. While it won’t shrink the overall filesize of bp, It will make the event graph much easier to read.