Create a new level, name as MainMenu
and a new widget, called MainMenu Widget
image.png

Create a Game Instance BP, called RTS_Game Instance
Go to project setting and change the game instance
image.png

Open the BP, add new custom event:
image.png
(capital letter on ?Listen)

Go to MainMenu Widget, graph, add on clicked event on both buttons:
image.png

Check world settings if it’s as below (esp for Gamemode overide):
image.png

Open MainMenu level→ Open Level BP, set the graph:
image.png
Change the number of players to 2
image.png

Go to RTS PlayerController,
Event begin play node modify:
image.png

Make a provision for the 2nd to 4th player to spawn


Go back to TopDown map level
Make a BP actor, called PlayerStartCamp
Add following box collisions and position them as below:
image.png
Drag the BP actor in 3 corners in the scene map
image.png
Create a Gamemode based BP, name as RTS GameModeBase
image.png
Go to project setting,
change the default gamemode to RTS game mode based,
and HUD, player controller:
image.png
In both MainMenu and TopDownMap levels, world settings, set gamemode overide to none:
image.png

Open RTS Game Mode Base, construction script:
promote variable, rename as PlayerStartCamps
image.png
To event graph (setup possessing camera when event starts)
image.png
To remove selected player when game starts:
image.png

To spawn Starting Building and Units made in previous tutorials before:



Add function in RTS interface:
image.png
Go to GameMode Base graph, add below nodes (to send player start camp to player controller):
image.png
Go to Player Controller graph, add “Event setup Player Start” node by different sequence, with “spawn actor from class” nodes for each unit class:
Collapse the highlighted nodes to marcos, name as Spawn Player Starting Loadout
image.png
Open the marco and plug all the “self” in inputs node from 4 to 1:
image.png
Delete self 2 to 4, rename 1st one as PlayerStartCamp
image.png
Back to event graph, R click on the spawn node and refresh node
image.png
To authorize only host but not clients player controllers to set spawning:
image.png

Go to Parent Unit Class, Details, Pawn
Change Auto Possess AI from Place in World to Place in World or Spawned
image.png
Choose Parent unit class self, check if tick Replicates
image.png
Go to Parent Building Class, check the same thing:
image.png

Now both units and building are spawn, but cannot move the unit. To solve this:

Go back to Player Controller BP:
Ending on Right mouse button event, revise below by creating a custom event to facility multiplayer setup:
Add custom event with 2 inputs, and change replicates to run on server
image.png
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.