Skip to content

14.Cost of Resource to construct units



Define unit cost and enforce them


Open Parent unit class:
Add integer variable
image.png
Open Unit style 1
Detail, resource amount to 150:
image.png
unit style 2, 200
Resource truck, 100

Go to player controller
In produce unit command, add follow (branch for false statement):
image.png

Create Resource not enough message


Go to MainUI Widget, add follow text, set variable, opacity 0:
image.png
image.png
in event graph:
Start by make custom event: Show not enough resources message:
image.png

Back to Player controller (for branch on true statement)
image.png

Collapse below into marcos, called Deduct Unit Resource Cost
image.png
image.png
Open the marcos, change follow input and output:
image.png
image.png

Setup (ToolTip) to show actual unit cost:


In Building Selected widget, add a horizontal box and rename it, set as variable:
image.png
Create a new interface, called RTS_Tooltips_Interface
add funciton:
image.png

Open Parent Building Class, add the interface
image.png
In event graph, start follow graph:
image.png

Create a new widget, called Unit1_ToolTip
image.png
Wrapping to 300 for double line texting
Border created by R click on horizontal box, wrap with border, then change its brush alpha and color

Duplicate the Unit1_ToolTip widget, for unit 2 and Truck

Associate tooltips made to production buttons:


Open Produce Unit1 Widget, event graph, create follow highlight nodes:
image.png

Duplicate the nodes above and put in Produce unit2, and produce truck widget
Want to print your doc?
This is not the way.
Try clicking the ··· in the right corner or using a keyboard shortcut (
CtrlP
) instead.