🚢
Airship
  • Getting Started
    • Welcome to Airship
    • Installing Airship
  • TypeScript
    • Overview
    • AirshipBehaviour
      • Adding Inspector Properties
      • AirshipSingleton
      • Using Component Decorators
      • Accessing Other Components
  • Publishing
    • Publish Game
    • Developer Console
  • Networking
    • Multiplayer
    • Local Server Mode
    • Network Signals
    • Network Functions
    • Network Identity
    • Network Transform
  • Input
    • User Input
      • Actions
      • Keyboard
      • Mouse
    • Proximity Prompts
  • Core Package
    • What is the Core Package?
    • Chat Commands
    • Inventory
    • Spawning Characters
    • Enable / Disable Core Features
  • Physics
    • Physics Settings
    • Physics Layers
  • Platform Services
    • Data Store
      • Locking
    • Cache Store
    • Leaderboards
    • Platform Inventory
    • Server Management
    • Server List
    • Server Transfers
    • Users
    • Parties
    • Matchmaking
    • External Services
  • CHARACTERS
    • Quick Configuration
    • Character Movement System
      • Character Movement Data
      • Character Movement Events
    • Character Camera
      • First Person Camera
      • Simple Usage
      • Camera Structure
      • Default Camera Modes
      • Disabling the Camera System
    • Character Animations
      • Character Blender Animations
      • Character Ragdoll
  • Accessories
    • Accessories Intro
    • Creating Accessories
    • Using Accessories
  • ANIMATIONS
    • Animation Events
  • Optimization
    • Live Game Profiler
    • Reducing Bundle Size
  • Game Settings
    • Game Visibility
  • Other
    • Project Status
    • FAQ
    • DataType Math
    • JS to Luau
    • Tags
    • Terrain
    • AirshipNetworkBehaviour
      • Lifecycle Events
      • ServerRpc
      • ObserversRpc
      • TargetRpc
    • VoxelWorld
      • Voxel World Getting Started
      • Voxel World Tips
      • Prefab Voxels
      • QuarterBlocks
    • Easy Helper Utils
      • Easy Motion
      • Easy Grid Align
      • Easy Look At
      • Easy Shake
      • Easy Destroy
Powered by GitBook
On this page
  • Events
  • Polling
  • Movement
  • Events
  • Polling
  1. Input
  2. User Input

Mouse

Events

There are individual events for the up and down events for left, right, and middle mouse buttons: onLeftDown, onLeftUp, onRightDown, onRightUp, onMiddleDown, onMiddleUp.

Mouse.onLeftDown.Connect(() => {
    print("Left button down");
});

Mouse.onLeftUp.Connect(() => {
    print("Left button up");
});

Polling

The state of each button can also be checked with the IsLeftButtonDown (et. al.) methods.

if (Mouse.IsLeftButtonDown()) {
    print("Left button down");
}

if (Mouse.IsRightButtonDown()) {
    print("Right button down");
}

if (Mouse.IsMiddleButtonDown()) {
    print("Middle button down");
}

Movement

Events

The Moved event fires when the mouse is moved. The onScrolled event fires when the scroll wheel is moved.

Mouse.onMoved.Connect((screenPosition) => {
    print("Mouse position", screenPosition);
});

Mouse.onScrolled.Connect((delta) => {
    print("Scrolled", delta);
});

Polling

Use the position field and GetDelta method to retrieve information about mouse movement.

// Get current position of mouse:
const screenPosition = Mouse.position;

// Get movement of mouse since last frame:
const delta = Mouse.GetDelta();
PreviousKeyboardNextProximity Prompts

Last updated 9 months ago