Airship
  • Getting Started
    • Welcome to Airship
    • Installing Airship
  • TypeScript
    • Typescript Overview
    • AirshipBehaviour
      • Adding Inspector Properties
      • AirshipSingleton
      • Using Component Decorators
      • Accessing Other Components
      • Lifecycles
  • Networking
    • Multiplayer
    • Local Server Mode
    • Network Signals
    • Network Identity
    • Network Transform
    • Network Functions
  • Publishing
    • Create Dashboard - Game CMS
      • Game Visibility
      • Game Loading Screens
    • Publish Game
    • Publishing with API Key
  • Core Package
    • What is the Core Package?
    • Chat Commands
    • Proximity Prompts
    • Inventory
    • Enable / Disable Core Features
    • Developer Console
  • Platform Services
    • Data Store
      • Locking
    • Cache Store
    • Leaderboards
    • Platform Inventory
    • Server Management
    • Server List
    • Server Transfers
    • Server Messaging
    • Users
    • Parties
    • Matchmaking
    • External Services
  • Unity For Airship
    • Quick Overview
    • DataType Math
    • Random
    • Resources Folder
    • Physics Settings
    • Physics Layers
    • Animation Events
    • User Input
      • Actions
      • Keyboard
      • Mouse
    • Easy Helper Utils
      • Material Color URP
      • Easy Motion
      • Easy Grid Align
      • Easy Look At
      • Easy Shake
      • Easy Destroy
  • Unity Asset Store
  • Packages
    • Import a Package
    • Creating a Package
    • Editing a Package
    • Common Packages
  • CHARACTERS
    • Character System
      • Spawning Characters
      • Custom Character
      • First Person Viewmodel
    • Player System
    • Character Movement System
      • Character Movement Hierarchy
      • Character Movement Physics
      • Character Movement Data
      • Character Movement Events
      • Character Movement Networking
        • Server Authoritative Movement
    • Character Camera
      • Custom Camera Mode
    • Character Animations
      • Character Rig Download
      • Character Ragdoll
  • Accessories
    • Accessories Intro
    • Creating Accessories
    • Using Accessories
  • Optimization
    • Live Game Profiler
    • Reducing Bundle Size
  • Other
    • FAQ
    • JavaScript -> Luau
Powered by GitBook
On this page
  1. CHARACTERS
  2. Character Movement System

Character Movement Physics

PreviousCharacter Movement HierarchyNextCharacter Movement Data

Last updated 9 days ago

CtrlK

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 characters rotation
character.movement.graphicTransform.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);
        }
    }
}