Best way to implement the heroes of a hero shooter?

I’m making a hero shooter game and wanted to what the best way to implement the characters should be?

The first thing my mind went to was having a “hero” parent class that has the functionality that every hero has like movement, animations, etc., as well as overridable functions for each ability. And then derive each unique hero from that class, overriding their unique abilities, their weapon, their animations, their mesh, etc.

But some people have told me that it would be better to use composition using components instead. I don’t have a lot of experience programming by composition or using components in Unreal, so I wasn’t really sure exactly what they meant.

What method(s) would be best for this?

Thanks in advance!

I highly recommend you download the Lyra project and even use it for you base game and expand on it.
It makes use of Gameplay Abilities to grant abilities to heroes and you’ll see how to customize animations and anything else you might need.
It’ll take some time to work though everything Lyra offers but it will be a great fit for what you need.

2 Likes

The Gameplay Ability System is Epic’s own solution to a very similar problem (I can’t be sure on this but IIRC it was made for Paragon) so it should be a relatively supported way of creating abilities that can be replicated over a network. I have personally not used it so that’s pretty much all I can say.

Generally speaking, avoid inheritance / overriding. They both do have reasons to exist but it often makes it harder to maintain code in the long run, especially if used for gameplay logic. Inheritance works fine when the base class is broad and/or well-defined.

A base class for the “hero character” is fine, but as an example, the abilities make more sense as components. It should make it easier to maintain (assuming not all the abilities are somehow directly interconnected with each other on every hero) and can allow gameplay features that would be hard to make in a more rigid system. Imagine a character that could copy abilities from other characters.

1 Like

A base class for the “hero character” is fine, but as an example, the abilities make more sense as components. It should make it easier to maintain (assuming not all the abilities are somehow directly interconnected with each other on every hero) and can allow gameplay features that would be hard to make in a more rigid system. Imagine a character that could copy abilities from other characters.

I don’t have a lot of experience with components and composition programming, so I’m unsure of what this would look like. Do you mean that every unique ability has its own component class? And how would this be integrated with input and the user interface?

I highly recommend you download the Lyra project and even use it for you base game and expand on it.

I had spent some time with Lyra before but struggled to understand how it works and the purpose of each of its systems. I tried to watch this video to get a better understanding, but I really have no clue what this guy is saying.

You would have a base class for an ability and use that, but then each ability added from base class would have its own class. The base class would only have very generic implementations like “activate ability” and such.

But you really shouldn’t make your own, because the Gameplay Ability System is added to the engine as a plugin.

1 Like

There is a lot to take in when working through Lyra, if you focus only on the parts you need initially then it won’t feel so overwhelming.
Use the Reference Viewer to find relationships between the parts you are interested in and work your way up and down the chain. I had to do this to start putting the pieces together.

You could start with creating a new ability and a new hero whom you give that ability to. The ability system is very powerful and worth understanding an making use of, for a more in depth understanding have a look at this: GAS

And this video: Guided Tour of GAS

To add to what @JoSF was saying, if you take the time to figure out Lyra you’ll save yourself a lot of time down the road because most of what you need it already implemented.

1 Like

That’s exactly what I was looking for. Thank you!