4.9 KiB
On Mouse Input node
Note
The On Mouse Input [!includenodes-note-manual]
The On Mouse Input node listens for a specific action on a user's mouse. The action doesn't need to happen on a specific GameObject's Collider. [!includenodes-desc-end]
Fuzzy finder category
The On Mouse Input node is in the Events > Input category in the fuzzy finder.
Inputs
The On Mouse Input [!includenodes-inputs]
Name | Type | Description | |
---|---|---|---|
Button | Mouse Button | The name of the mouse button that triggers the On Mouse Input node. | |
Action | Press State | The specific state of the mouse button that the node listens for. | |
Hold | The user holds down the mouse button. | ||
Down | The user presses the mouse button. | ||
Up | The user releases the mouse button. |
Additional node settings
The On Mouse Input [!includenodes-additional-settings]
[!include[nodes-coroutine](./snippets/nodes-coroutine.md)]Name | Type | Description |
---|
Outputs
The On Mouse Input [!includenodes-single-output]
[!include[nodes-input-output-trigger](./snippets/input-manager/nodes-input-output-trigger.md)]Name | Type | Description |
---|
Example graph usage
In the following example, the On Mouse Input node listens for the user to hold the right mouse button and triggers an Instantiate Camera node. The Instantiate node clones the camera saved as the Camera1 Scene variable and assigns it to the NewCamera Scene variable. It sets a new position for the cloned camera with a Transform Set Position node, before it switches which camera renders in the Game view with the Camera Render node.
When the application runs, the default view in the Game view displays all three spheres in the scene.
When the user holds the right mouse button and triggers the On Mouse Input node, the Game view changes to focus on the middle sphere.
Related nodes
[!includenodes-related] On Mouse Input node: