Next: , Previous: , Up: Interaction   [Contents][Index]


9.3 Mouse Commander

Component: MouseCommander

This component implements RTS-style camera motion and object deployment. Legacy GUI is not recommended for mobile. To use, add this to your MainCamera (which must be tagged ’MainCamera’) and then set up a list of deployable objects. This works with the ’ResourceManager’ component (optionally) to allow for a resource-based experience.

There is a more in-depth manual ’MouseCommanderDoc.rtf’ found in the MultiGame/Scripts/Interaction/RTS folder in your project, explaining the system in more detail than can fit in this text box.

Field of MouseCommander: LayerMask deployMask

What objects can we deploy on, by collision mask?

Field of MouseCommander: List<string> selectableTags

What objects can be selected using banding boxes?

Default value: new List<string>()

Box Selection

Field of MouseCommander: bool boxSelect

If enabled, we will draw a box on screen when the user clicks and drags the mouse, and select anything inside that box tagged with one of the ’SelectableTags’

Default value: true

Field of MouseCommander: Rect selectableArea

What area of the screen is available for selection? Clicks outside of this area are ignored. This is represented as a ’Normalized Viewport Rectangle’, where each value indicates a percentage of screen space represented as a decimal value between 0 and 1.

Default value: new Rect(0,0,1,1)

GUI Settings

Field of MouseCommander: bool useGUI

Should we use Unity’s legacy GUI for this? Not suitable for mobile devices

Default value: true

Field of MouseCommander: Layouts layout

Which direction should the buttons be drawn in?

Default value: Layouts.Horizontal

Field of MouseCommander: Rect guiArea

Normalized viewport rectangle indicating where we should draw the buttons. Numbers indicate a percentage of screen space from 0 to 1

Default value: new Rect(0.01f, 0.88f, .98f, .11f)

Input and Motion

Field of MouseCommander: bool controlPosition

Should we control the position of this object using a rigidbody? Useful for command cameras

Default value: true

Field of MouseCommander: float deadZone

Stick dead zone, for control smoothing

Default value: 0.25f

Field of MouseCommander: float force

Movement force to apply

Default value: 1000.0f

Field of MouseCommander: float ySpeed

How fast does the scroll wheel move us?

Default value: 20.0f

Field of MouseCommander: KeyCode continuationModifier

What key, if any, can the player hold down to keep deploying more of the same thing?

Default value: KeyCode.LeftShift

Deploys and Resources

Recommended Field of MouseCommander: string radiusSearchTag

Tag of objects we can’t deploy close to

Default value: ""

Field of MouseCommander: Deployable[] deploys

What objects can the player buy?

Message Senders

Field of MouseCommander: MessageManager.ManagedMessage insufficientResourceMessage

Sent when we can’t afford something

Field of MouseCommander: MessageManager.ManagedMessage itemSelectedMessage

Sent when we can afford a selection

Field of MouseCommander: MessageManager.ManagedMessage itemTooCloseMessage

Sent when we failed to deploy something due to radius restriction

Field of MouseCommander: bool debug

Send useful information to the console

Default value: false

Available Messages

Message on MouseCommander: SelectDeploy (int)

Activate deployment for a ’Deployable’

Argument: Index indicating which of the ’Deploys’ you wish to allow the player to place ’

Message on MouseCommander: Deploy (int)

Deploys the designated object immediately at the mouse position

Argument: The index of the Deployable you wish to deploy.

Available Messages

Message on MouseCommander: EnableBoxSelect ()

Allows banding box selection by clicking and dragging.

Message on MouseCommander: DisableBoxSelect ()

Disables banding box selection across the entire screen.

Message on MouseCommander: ToggleBuildGUI ()

Opens/closes the build GUI

Message on MouseCommander: EnableBuildGUI ()

Opens the build GUI

Message on MouseCommander: DisableBuildGUI ()

Closes the build GUI

Field of MouseCommander: LayerMask deployMask

What objects can we deploy on, by collision mask?

Field of MouseCommander: List<string> selectableTags

What objects can be selected using banding boxes?

Default value: new List<string>()

Box Selection

Field of MouseCommander: bool boxSelect

If enabled, we will draw a box on screen when the user clicks and drags the mouse, and select anything inside that box tagged with one of the ’SelectableTags’

Default value: true

Field of MouseCommander: Rect selectableArea

What area of the screen is available for selection? Clicks outside of this area are ignored. This is represented as a ’Normalized Viewport Rectangle’, where each value indicates a percentage of screen space represented as a decimal value between 0 and 1.

Default value: new Rect(0,0,1,1)

GUI Settings

Field of MouseCommander: bool useGUI

Should we use Unity’s legacy GUI for this? Not suitable for mobile devices

Default value: true

Field of MouseCommander: Layouts layout

Which direction should the buttons be drawn in?

Default value: Layouts.Horizontal

Field of MouseCommander: Rect guiArea

Normalized viewport rectangle indicating where we should draw the buttons. Numbers indicate a percentage of screen space from 0 to 1

Default value: new Rect(0.01f, 0.88f, .98f, .11f)

Input and Motion

Field of MouseCommander: bool controlPosition

Should we control the position of this object using a rigidbody? Useful for command cameras

Default value: true

Field of MouseCommander: float deadZone

Stick dead zone, for control smoothing

Default value: 0.25f

Field of MouseCommander: float force

Movement force to apply

Default value: 1000.0f

Field of MouseCommander: float ySpeed

How fast does the scroll wheel move us?

Default value: 20.0f

Field of MouseCommander: KeyCode continuationModifier

What key, if any, can the player hold down to keep deploying more of the same thing?

Default value: KeyCode.LeftShift

Deploys and Resources

Recommended Field of MouseCommander: string radiusSearchTag

Tag of objects we can’t deploy close to

Default value: ""

Field of MouseCommander: Deployable[] deploys

What objects can the player buy?

Message Senders

Field of MouseCommander: MessageManager.ManagedMessage insufficientResourceMessage

Sent when we can’t afford something

Field of MouseCommander: MessageManager.ManagedMessage itemSelectedMessage

Sent when we can afford a selection

Field of MouseCommander: MessageManager.ManagedMessage itemTooCloseMessage

Sent when we failed to deploy something due to radius restriction

Field of MouseCommander: bool debug

Send useful information to the console

Default value: false

Available Messages

Message on MouseCommander: SelectDeploy (int)

Activate deployment for a ’Deployable’

Argument: Index indicating which of the ’Deploys’ you wish to allow the player to place ’

Message on MouseCommander: Deploy (int)

Deploys the designated object immediately at the mouse position

Argument: The index of the Deployable you wish to deploy.

Available Messages

Message on MouseCommander: EnableBoxSelect ()

Allows banding box selection by clicking and dragging.

Message on MouseCommander: DisableBoxSelect ()

Disables banding box selection across the entire screen.

Message on MouseCommander: ToggleBuildGUI ()

Opens/closes the build GUI

Message on MouseCommander: EnableBuildGUI ()

Opens the build GUI

Message on MouseCommander: DisableBuildGUI ()

Closes the build GUI


Next: , Previous: , Up: Interaction   [Contents][Index]