🚢
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
  • Overview
  • Setting Up Your Movement System
  • The Physics Setup
  • Animations
  1. CHARACTERS

Character Movement System

How to work with Airships core character movement system

PreviousQuick ConfigurationNextCharacter Movement Data

Last updated 9 months ago

Overview

When spawning in a default Character you get the benefit of several different movement features for your game.

  • Jogging - Default movement

  • Sprinting - Faster movement

  • Crouching - Slower movement with a lower hitbox

  • Jumping - single or multi jump with controls for upward and downard force

  • Flying - A no gravity mode for vertical movement (useful in debugging levels)

  • Step Ups - Automatically step up to higher colliders smoothly

  • Slopes - Control how fast slopes pull you down and what slopes you can move and jump on

  • Knockback - Easily add forces to the character

The system is built with a Rigidbody and Box Collider. You can apply forces or directly override the velocity to add custom movement mechanics.

There are two main components for Movement. CharacterMovement which has all the logic for controlling movement, and CharacterMovementData which has all of the exposed variables for fine tuning your system.

Setting Up Your Movement System

After creating your own Character prefab variant, you can customize the system as you see fit. Open up your Character prefab and scroll to the CharacterMovementData component in the inspector.

The Physics Setup

The character is controlled by a Rigidbody and Box Collider. The Box Collider is axis aligned. Meaning the root of your character DOES NOT ROTATE.

The rotation happens purely on the graphical elements of the hierarchy. Specifically on the NetworkedGraphicsHolder. So if you want to get the rotation of the character you will need to grab the rotation from that transform, or use the look vector from the CharacterMovement component

//To get the NetworkedGraphicsHolder rotation
character.movement.networkTransform.rotation;

//To get the look vector of the character
character.movement.GetLookVector();

The rigibodies forces are controlled by the CharacterMovement component. If you want to add forces you can use the Impulse functions. If you want to control the velocity you can use the SetVelocity function.

//Add an instant force to the characters rigidbody
character.movement.AddImpulse(Vector3.forward.mul(10));

//Stop all motion
character.movement.SetVelocity(Vector3.zero);

Its easy to check if another component has collided with the characters. Simply check for the Character component, or any other component on the root of the Character prefab.

import Character from "@Easy/Core/Shared/Character/Character";

export default class KnockbackCollider extends AirshipBehaviour {
    public knockbackForce: Vector3;

    protected OnTriggerEnter(collider: Collider): void {
        let character = collider.attachedRigidbody?.gameObject.GetAirshipComponent<Character>();
        if(character){
            //Interact with character
            character.movement.AddImpulse(this.knockbackForce);
        }
    }
}

Animations

The animations of the characters movements will be automatically synced to the CharacterMovement state and networked to other players.

You can see a breakdown of the variables

On This Page