Enemy groups

I am working on a small rts game and trying to find a good approach on how to make enemies with their bases and building the way they can know which building is their and which one is not.

I have made units to have different Actor parents and that way units know that another unit is friendly or enemy.

With Buildongs I have a bit of a problem. I do not want to make lots of buildings with the same behaviour but different names to make units know about which building belong to which team.

Thus, if someone knows any discent approach for that I will appreciate any link to a good explanation.

Best regards.

Hi, you can also create an enum for faction. for example:

UENUM(BlueprintType)
enum class EFaction : uint8
{
   EF_Ally,
   EF_Enemy

};

and assign that EFaction to each building. So when your ally build something, Set that EFaction to Ally, and the enemy also do that but the faction is Enemy.

Also assign that EFaction to the characters (Enemy, Ally, n Chara)

When the enemy / AI want to look for the building for the action, you can check, Is this building have the same faction with the AI? if its the same then it is the building that Its team built, if it is different faction, then you should attack / raid.

You can do something like that.

Thanks, I did kind the same with TeamID and also tried with Tags to set for the team name. I just decided to ask others opinions about it as maybe someone will give me a better idea, you know?

Now when the game becomes bigger I need to perform too many checks for the resources, units, buildings and I need to check each and everything for the tag and team id. So, kinda a bit of work.

But thanks for the reply.

1 Like

I see, if there is another way that better and faster, I hope to know it too then bcs I don’t know the better way