Download

Adding a Team attribute to the Actor class

I need to have a Team number that can be assigned to actors, preferably in such a way that it can be accessed from the blueprints. Is there an easy way to do this without hacking Actor.h?

There are 2 ways:

  1. Make a class ATeamActor that derives from AActor and let every custom actor derive from it (there you can put your properties in).

  2. Make a team component. Assign it to every actor who needs team-awareness.

I added an ATeamActor class derived from AActor via c++ and recompiled. But I can’t seem to access it anywhere. I’m guessing I missed a step someplace.

Did you add the class via the wizard in the editor? If not then you need to make sure you add the required macros to the class declaration or the UE build tool will ignore it. The easiest way is to go File->Add Code to Project… and follow the wizard.

Perhaps post the code for your ATeamActor class so we can have a look?

Yes, I used the class wizard. I haven’t added anything to it yet. It’s just the template the wizard creates. I was checking to see if it showed up for use.

When you compiled the project in visual studio are you using the Development Editor configuration?

Using Linux.

Ok, I guess I can’t really help then, but I assume that whatever compiler you’re using for linux (presumably gcc?) has a similar build flag which needs to be switched?

Anything you place in a level that has a position is an Actor. Do you really want each rock, tree, sound effect, etc, to have a Team?
Maybe you instead want the team on your Pawn, or even on your Character?
The way to do it in blueprint is to define an ITeam interface in Blueprints, and make each of your player-actor classes implement this interface.

Having the team parameter in the base class is pretty standard. Things like trigger volumes, anything that can be damaged, sounds, etc., may restrict which team interacts with it.