move method

CharacterMovement move(
  1. Vector3 desiredTranslation, {
  2. double? deltaSeconds,
})

Moves by up to desiredTranslation, sliding along obstacles, and applies the corrected translation to the node.

deltaSeconds defaults to the world's fixed timestep; call once per fixed step.

Implementation

CharacterMovement move(Vector3 desiredTranslation, {double? deltaSeconds}) {
  final world = _world;
  final collider = _collider;
  if (world == null || collider == null) {
    throw StateError('move() before the controller is mounted');
  }
  final transform = node.globalTransform;
  final position = transform.getTranslation();
  final movement = world.simulation.moveCharacter(
    collider.handles.first,
    position: position,
    desiredTranslation: desiredTranslation,
    deltaSeconds: deltaSeconds ?? world.fixedTimestep,
    up: up,
    offset: offset,
    slide: slide,
    maxSlopeClimbAngle: maxSlopeClimbAngle,
    minSlopeSlideAngle: minSlopeSlideAngle,
    snapToGround: snapToGround,
    autostep: autostep,
    autostepMaxHeight: autostepMaxHeight,
    autostepMinWidth: autostepMinWidth,
    autostepIncludeDynamicBodies: autostepIncludeDynamicBodies,
    characterMass: mass,
  );
  node.globalTransform = transform.clone()
    ..setTranslation(position + movement.translation);
  return movement;
}