All projects
BabylonJS

BabylonJS Character Controller V2

Full character controller in BabylonJS — keyboard + gamepad input, blend tree animations, collision, camera follow. Drop-in reusable system.

Rebuilt from scratch after V1 had animation blending issues and tight mesh-name coupling. Works with any GLB using standard Mixamo/RPM bone naming.

BabylonJS Character Controller V2
Keyboard + gamepad, blend tree, capsule physics, mobile joystick

Architecture

Two modular classes: AnimCtrl (skeletal animation blend tree) and CharCtrl (input + physics). Config consolidated in DEFAULT_CHAR_CONFIG — one place for all tunable values.

Features

  • Input: keyboard + gamepad unified through the same action map
  • Animations: blend tree smoothly transitions Idle → Walk → Sprint with weight lerping
  • Physics: capsule collider (stable, no mesh-collider jitter), slope alignment, squash-and-stretch on landing
  • Camera: adaptive lerped follow, dynamic FOV expansion at higher speeds, mobile framing adjustments
  • Mobile: glassmorphism virtual joystick, settings persisted via localStorage
  • Crouch + sprint: operate as toggles that coexist (high-speed crouched running works)

Asset pipeline

Uses the FBX2GLB batch tool — animations merged and optimized into a single compressed GLB.

V1 → V2

V1V2
InputKeyboard onlyKeyboard + Gamepad
ColliderMeshCapsule
AnimationsStart/stopBlend tree
CouplingTight to mesh namesConfig-driven

Built by

Viseni Design Studio

3D, WebGL, interactive & VR/AR experiences

Visit viseni.com