7.Multiplayer Setup & player starting camp

8.Setup Teams & Team coloring



Open GameMode base BP:
Add variables:
image.png
In team color Details, add 4 team colors:
image.png

Add 2 new inputs in SetupPlayerStart functions in RTS Interface:
Single linear color here, not array
image.png
Back to Game mode base graph, revise setup player start node as below
(GET node typed Get a Copy, not Get a Ref)
image.png
Continue to elaborate:
image.png

Go to PlayerController BP
promote variables for number and color in Event Setup player start node:
image.png
Set Team number variable in detail, replication as Replicated:
image.png

Go to Parent Unit Class,
add variables for color and number
image.png
For both variables in details, tick instance editable, expose on spawn, and turn replication to Replciated:
image.png

Go to Parent Building Class
Repeat the same as parent unit class
image.png

Go to player controller, Spawn players starting loadout marcos,
Refresh all spawn actor first building nodes, plug in team numbers and color variable nodes:
image.png

Go to Unit style 1, open its mesh’s material graph, R click and convert the color node as parameter,
rename it as TeamColor (for BP use):
image.png

Back to Parent Unit class, setup team color graph in event begin play node:
image.png

Repeat the same on building → Open First Building viewport, open its material:
image.png
In Parent Building Class:
image.png

Make team numbers (for selection of units from the other team):


Add 2 new functions in Interface:
image.png
image.png

Go to Parent unit class, open Get Team function node in Interface and make the graph:
image.png

Repeat the same on Parent Building Class BP

Go to Player Controller, open Is on my Team? function in interface:
image.png

Go to Marquee HUD BP, add nodes to identify team after for each loop, and before select units under rectangle graph:
(The branch true refers to only select the units, if it’s on my team)
image.png

To do the same on selecting building, go to RTS player controller, open Handle Building Click marco in left mouse button node graph:
image.png

Now the player can only select his own units and buildings
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.