Creating an RTS game, both players can control all the units.. how do I make it so they only have access to their own units?

This is my first post on the forums woot! If I made any mistakes in my posting please let me know.

So I’m creating this RTS game, everything is going pretty well. I’m stuck on this aspect though, the title of my post… I am able to get 2 players entered and they possess their own cameras at their own player starts. But I’m unsure how to make them only able to control their units and not the enemy units. Currently you can scroll over to the enemy base and just select and control their units as if they were your own. I need a way to distinguish between the two.

I have added selection decal indicators for all the units, and based on whether their “Player Unit” Boolean variable is set to true or false, the selection indicator decal will display as blue or red. So if they are an enemy the Player Unit boolean should be false, so when you click on them it will be red. Not sure if this info will help.

I am using only Blueprints as I am not C++ proficient.

At the moment I’m not even sure what blueprints I should screenshot to help fix this.

This is the code I have for the Main Base building to start creating a worker. Not sure if this will help, but I’m thinking when it spawns I need to assign it to a player somehow.

Thank you in advance for any help. :]

Without knowing more, my best guess is that all of your units are getting this Boolean flag activated for every player.

My guess is that you need more information to tie the units to their specific player.

Example approach:
When a player joins the game they should be assigned some kind of unique ID, a GUID or something similar that will be unique to that player. All of your units should then have a PlayerID property that gets assigned this ID for their respective player. This way you can check if the Player clicking on the unit has the correlating ID and therefore has access to control it or not.

Thank you Fenix.

I was trying to implement this very idea but I am not sure how. I will keep tinkering. I’m not familiar with GUID so I think I will start there. I will post updates once I get it down.