Whats better? C++ Components or classes?

Hey there…

since i am new to the c++ thingy i wanted to know what is the better way?

Let’s say i have one Player (AActor). Then i wan’t some methods or functions. And like in blueprints the function geting more and more. I think, the more functions it have, sometime it is too hard to read the Code.
So i came to the idea to use c++ components. I could take functions that i do not Need often in that component.

What do you do with your Code? What’s the best mix of both?

It may be better to use components for things that are intended to be used in multiple different actors.
If you just want to separate a single actor mechanics implementation and responsibilities, UObjects or AInfos may be a better choice.

Another thing to keep in mind is that actor components can be replicated very easily. Just set YourComponent->SetIsReplicated(true) and your component will be replicated with RPCs enabled and will share the same network owner as its parent actor.

Thanks. I will try to use both. C++ is harder at the beginning as with blueprints. But i want to learn this stuff. Thanks for the answer

Like Sveitar said, outsourcing code to components can be a good idea if you want to reeuse that functionality on other actors. Sometimes components, like the character movement component, are only meant to be used with one specific actor class. That can make sense if you want cleaner code and pull functionality apart, which could for example make sense if you add an inventory management component to your character. However I would not use it to outsource certain functions that are only called rarely, because acessing the component from the actor and then the actor from the component function probably makes it more complicated than just having the function on the actor class, plus you could also add a seperate .cpp file for specific function bodies like done with the Actor class and ActorReplication.cpp.