Create Golden Mineral Nodes
Create a BP actor, called ResourceNode
Make follow mesh
untick affect navigation
Open TopDown Map level, place the resource nodes and relocate the PlayerStartCamp units at 4 corners closer to each other
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
Change capsule size to 20,20, move the cube inside the capsule
Child a new static mesh under Body, called Nose
And then another mesh, called Spinner
To make the spinner rotate on the top of truck:
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:
To apply the team color for new meshes:
Go to Parent Unit Class, add variables:
Replace Mesh variable before Setup Team color command:
delete the mesh nodes
Open Unit Style 1, construction script:
Repeat the same on Unit Style 2
In Resource Truck, construciton script,
duplicate the ADD node, and connect with Nose, Spinner components as such:
Test it
To fix the movement of Trucks not too jerky:
Open Parent unit class, select the root in component, untick Rotation Yaw
Go to Character movement component, tick use controller desired rotation
Mining the mineral nodes
Create a new BP interface called RTS Resource Interface
Add functions as:
For set is working, add input:
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)
Now the set is working needs to call the server by new custom event:
Replicates: Run on server
Make the new graph by disconnect Set is not working node that made before:
*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:
Make variables for event set is working node:
Graph as (in == node, drag out and typed get team number to get such node
Continue, add a float variable, closest drop off building distance, default value as 5000:
if for each loop is completed after find nearest dropoff point, will move to next target:
Add another boolean variable, hasReource?
Overall:
To create overlapping interaction of the trucks (23:30):