character_controller_up_vector
The up vector instructs the character controller of what direction should be considered vertical. The horizontal plane is the plane orthogonal to this up vector. There are two equivalent ways to evaluate the slope of the floor: by taking the angle between the floor and the horizontal plane (in 2D), or by taking the angle between the up-vector and the normal of the floor (in 2D and 3D). By default, the up vector is the positive y axis, but it can be modified to be any (unit) vector that suits the application.
- Example 2D
- Example 3D
let characterController = world.createCharacterController(0.01);
// Change the character controller’s up vector to the positive X axis.
characterController.setUp({ x: 1.0, y: 0.0 });
let characterController = world.createCharacterController(0.01);
// Change the character controller’s up vector to the positive Z axis.
characterController.setUp({ x: 0.0, y: 0.0, z: 1.0 });