🚢
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
  • Basic Actions
  • Core Actions
  • Modifier Keys
  • Update Action Binding
  1. Input
  2. User Input

Actions

Basic Actions

Actions let you define input bindings that your players can rebind from the settings menu.

// Define an action
Airship.Input.CreateAction("Dash", Binding.Key(Key.LeftShift));

// Listen to using the action
Airship.Input.OnDown("Dash").Connect(() => {
    print("Dash!");
});

Core Actions

You can also hook into core actions or disable them in your game. Listening to core actions allows you to share a player's preferred keybinds from other games.

// Disable core jump & sprint actions
Airship.Input.DisableCoreActions([CoreAction.Jump, CoreAction.Sprint]);

// Listen to core primary action (by default left click)
Airship.Input.OnDown(CoreAction.PrimaryAction).Connect(() => {
    print("Swing sword");
});

Modifier Keys

For multi-key input you can create an action with a modifier key. Players can also rebind any actions to include a modifier.

// Dash on Shift+G
Airship.Input.CreateAction("Dash", Binding.Key(Key.G, ModifierKey.LeftShift));

// Print out key display
const dashAction = Airship.Input.GetActions("Dash")[0]
const keyDisplay = dashAction.binding.GetDisplayName();
print("Press " + keyDisplay + " to dash!")
// prints "Press Left Shift + G to dash!"

Update Action Binding

You can change a binding for a player through code. Unlike when a player changes their settings your binding changes will not be saved for the player beyond this session.

dashAction.UpdateBinding(Binding.MouseButton(MouseButton.LeftButton));
PreviousUser InputNextKeyboard

Last updated 9 months ago

Settings menu after running the code snippets. Players can rebind any action without any work on your end.