Make Units showed in Building selected widgets
Create a widget, called Produce unit 1 widget
Change to custom on screen
Add button and image (add unit 1 image in brush) layers, set widget padding as 3
go to graph, add on click event on the button,
add variable building Reference
Add function in RTS interface with 2 inputs
Back to Produce unit 1 widget
Duplicate the widget, name as unit 2 widget (and so on for more units)
Replace the image and event graph produce unit to unit 2:
Go to Parent Building class, event graph, add action box variable:
extend nodes at end of Create building selected widget commands:
Go to First Building BP, event graph set
for create widget unit 1, then unit 2, thn begin play parent:
Set action in the unit box:
Go to PlayerController, event graph,
add event produce unit and custom event node: Server Add Unit to Queue (set the details setting):
Go to Parent Building Class, custom event: Add Unit to Queue:
Add a new variable, replicated:
Still in Parent Building Class, drag the new variable:
To deal with actual production of the unit itself, add pin on event begin play sequence:
default value on production timer graularity
Continue :
(set Timer by event node, tick Looping, or else won’t produce any unit upon clicking on action box)
Introduce a time needed to produce the unit:
Go to Parent unit class, add variable:
Go to Unit Style 1 BP, set production time e.g. 4
repeat the same on unit style 2
Back to Parent Building Class, graph:
For branch true side:
Add a variable:
Promote variable from divide node, set the production progress variable as replicated:
Add a box collision component, called Unit Spawn Point (a location where unit will be produced)
scale it down to 0.2 on xyz
Go to First building BP, the unit spawn point is inherited here from the parent class
drag the point a bit out of the mesh:
Back to Parent Building Class, set the following graph after SET production progress node:
Overall:
Go to Player Controller, event graph, complete custom event node with Add unit to Queue (created in Parent Building class as custom event):
Go to Building selected widget (bind values to producing building):
On Unit Production Image layer, Create bind on Brush
In progress bar layer, bind Percent:
On Unit production image 1 layer, bind the brush again:
copy highlight nodes above, repeat on image 2 and 3 layer graphs
Change is valid index and get nodes value to 1 in image 2, 2 to image 3, return value image size 50x50
To control visibility of “Text +” layer, go to graph:
open GetVisbility_0 funciton, add follow highlighted nodes:
Copy and paste the highlighted nodes on function Get unit production image 1 visibility:
Repeat the same on image 2 and 3 visibility functions, but change is valid index to 1 on image 2, 2 on image 3:
Back to Parent Building Class, replicate on Unit Being Produced variable:
(To let show the unit production image when producing unit as a client)