7.Multiplayer Setup & player starting camp

11.Resource (gold mining) Collection



Create Golden Mineral Nodes


Create a BP actor, called ResourceNode
Make follow mesh
untick affect navigation
image.png
image.png

Open TopDown Map level, place the resource nodes and relocate the PlayerStartCamp units at 4 corners closer to each other
image.png

Create a Resource Truck


Create child BP from Parent unit class, rename as ResourceTruck
Add static mesh component, name as Body, use a shape cube as mesh, scale down to 0.2
image.png
Change capsule size to 20,20, move the cube inside the capsule
image.png
Child a new static mesh under Body, called Nose
image.png
And then another mesh, called Spinner
image.png

To make the spinner rotate on the top of truck:
image.png

To change the units mesh in the game:


Go back to main menu level,
Open player controller, Spawn Players Starting Loadout:
change Class in spawn actor unit style 1:
image.png

To apply the team color for new meshes:


Go to Parent Unit Class, add variables:
image.png
Replace Mesh variable before Setup Team color command:
image.png
delete the mesh nodes

Open Unit Style 1, construction script:
image.png
Repeat the same on Unit Style 2

In Resource Truck, construciton script,
duplicate the ADD node, and connect with Nose, Spinner components as such:
image.png
Test it

To fix the movement of Trucks not too jerky:


Open Parent unit class, select the root in component, untick Rotation Yaw
image.png
Go to Character movement component, tick use controller desired rotation
image.png

Mining the mineral nodes


Create a new BP interface called RTS Resource Interface
Add functions as:
image.png
For set is working, add input:
image.png

Implement Right click to collect resource on resource nodes:


Go to Player Controller, event graph,
Right mouse button node, start from break it result node, hit actor:
(units in grab selected units node should connect to array in for each loop node)
image.png
Now the set is working needs to call the server by new custom event:
Replicates: Run on server
image.png
image.png
Make the new graph by disconnect Set is not working node that made before:
image.png
*for each loop node may have to re-do, to connect target input on server pass thru set is working node

Go to Resource truck, event graph
Add RTS rerouse interface in class setting:
image.png
Make variables for event set is working node:
image.png
Graph as (in == node, drag out and typed get team number to get such node
image.png
Continue, add a float variable, closest drop off building distance, default value as 5000:
image.png

if for each loop is completed after find nearest dropoff point, will move to next target:
Add another boolean variable, hasReource?
image.png
Overall:
image.png

To create overlapping interaction of the trucks (23:30):

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.