Skip to content

PointAndClickRTSLogic ​

Inherits: ControllerLogic < Resource

Point-and-click RTS-style controller Left-click: Select units (drag for group selection) Right-click: Issue commands (move, attack, interact) Shift: Add/remove from selection

Properties ​

boolallow_drag_selectiontrue
intmin_drag_distance_squared1
boolshift_multi_selecttrue
ControllerLogic.SecondaryActionTriggersecondary_action_triggerControllerLogic.SecondaryActionTrigger.PRESS
boolallow_formation_movementtrue
FormationSystem.FormationTypedefault_formationFormationSystem.FormationType.LINE
boolright_click_smart_commandtrue
boolsmart_cast_abilitiestrue
boolallow_mouse_interacttrue
boolallow_keyboard_interacttrue
boolmovement_cancels_casttrue
boolauto_face_target_on_attacktrue

Variables ​

Array[Entity]selected_units[]
FormationSystemformation_system
boolmouse_left_clickfalse
Vector3drag_start_position_3d
Vector2drag_start_position_2d
Dictionarypending_interaction_targets{}

Methods ​

voidsetup( pc: PlayerController )
voidcleanup()
voidhandle_input_event( event: InputEvent )
voidprocess_input( delta: float )
Array[Entity]get_selected_units()
Array[LookBinding]get_look_bindings()
voidon_click_completed( button_index: int, position: Vector2 )
Array[int]get_exclusive_buttons()
Entityget_current_player()
voidselect_single_player( player: Entity )
voidtoggle_player_selection( player: Entity )
Stringget_type_display_name()

Property descriptions ​

RTS Selection

bool allow_drag_selection = true ​

Enable drag-box selection

int min_drag_distance_squared = 1 ​

Minimum drag distance squared to trigger drag selection

bool shift_multi_select = true ​

Allow Shift+click to add/remove from selection

RTS Commands

ControllerLogic.SecondaryActionTrigger secondary_action_trigger = ControllerLogic.SecondaryActionTrigger.PRESS ​

When the right-click command fires. RELEASE_WITHOUT_DRAG lets a camera that uses right-drag to look (e.g. third-person) tell "click to command" from "drag to look".

bool allow_formation_movement = true ​

Enable formation movement for multiple units

FormationSystem.FormationType default_formation = FormationSystem.FormationType.LINE ​

Default formation type for group movement

bool right_click_smart_command = true ​

Right-click intelligently chooses action (attack/move/interact)

bool smart_cast_abilities = true ​

Smart cast abilities without entering targeting mode

Interaction

bool allow_mouse_interact = true ​

Allow mouse-click interactions

bool allow_keyboard_interact = true ​

Allow keyboard (E/F) interactions

Movement

bool movement_cancels_cast = true ​

Moving a unit cancels active casts

bool auto_face_target_on_attack = true ​

Auto-face target when attacking

Variable descriptions ​

Array[Entity] selected_units = [] ​

Runtime state (not exported)

FormationSystem formation_system ​

Places the selected units in a formation when they are sent somewhere.

bool mouse_left_click = false ​

True while the left button is held.

Vector3 drag_start_position_3d ​

Where in the world the drag selection started.

Vector2 drag_start_position_2d ​

Where on the screen the drag selection started.

Dictionary pending_interaction_targets = ​

What each unit goes to interact with, by unit.

Method descriptions ​

void setup( pc: PlayerController ) ​

Sets the logic up when it becomes the one in use.

void cleanup() ​

Lets go of what the logic holds when it is replaced.

void handle_input_event( event: InputEvent ) ​

Handles one input event (a click, a key).

void process_input( delta: float ) ​

Handles the input of one frame.

Array[Entity] get_selected_units() ​

The entities the player has selected.

Array[LookBinding] get_look_bindings() ​

With RELEASE_WITHOUT_DRAG: report a right-click only if the pointer was not dragged (a camera that uses right-drag to look then waits for the drag instead of starting at the press)

void on_click_completed( button_index: int, position: Vector2 ) ​

Called when a click ends (the button and the place on the screen).

Array[int] get_exclusive_buttons() ​

LMB press/drag/release is this controller's own drag-box selection, so no camera may also claim it for a look gesture (e.g. the third-person camera's left-drag orbit)

Entity get_current_player() ​

The player the logic controls now.

void select_single_player( player: Entity ) ​

Selects one player.

void toggle_player_selection( player: Entity ) ​

Adds the player to the selection, or takes it out.

String get_type_display_name() ​

The name of the logic in the editor.