Log inGet started
Package

feel.module

Newest version

This package holds more than this page lists. See all of its files in its world.

README.md

feel

The rules that give a character its feel, shared by the CharacterController component and the package's character module (Velocity.resolve and the state machine), so both answer the same settings the same way.

Exports

  • Feel.DEFAULTS: the feel a character has when nothing states another (acceleration 20, braking 30, jumpForce 5, jumpHeight 0, jumpApexTime 0, minJumpHeight 0, fallGravityMultiplier 1, maxFallSpeed 0).
  • Feel.walk(vx, vz, wantX, wantZ, acceleration, braking, dt) -> (vx, vz, dx, dz): the ground velocity after dt seconds of walking toward the request, and the distance covered across the ground over them, exact for that motion. It speeds up along the request at acceleration, slows at braking, sheds the part across the request at braking, and brakes to a stop before a reversal speeds up the other way. 0 for either reaches the request at once.
  • Feel.launch(settings, pull, held) -> (speed, rise): the take-off speed of a jump and how it rises, from jumpForce, jumpHeight, jumpApexTime and minJumpHeight, against the gravity pull (m/s², positive pulling down). held says the jump was asked for with the jump control held, which makes it one a release cuts.
  • Feel.release(vy, rise, held) -> (vy, rise): a jump asked for held, once the control reads let go during its rise (on the step it takes off, for a request let go before then), is cut to the speed that tops it out minJumpHeight above where it was.
  • Feel.vertical(vy, dt, rise, pull, settings) -> (dy, vy, rise): one step along up off the ground, integrated exactly: a rising jump against its own gravity, a fall at pull * fallGravityMultiplier, no faster than maxFallSpeed. A step crossing the top switches gravity there, so the stated height and apex time hold at any frame rate.
  • Feel.jumpsAfter(jumpCount, maxJumps, footing) -> number?: the jump count a granted request leaves, or nil. On its feet or within coyote time (footing) a character takes its first jump; past it the jump from the ground counts as spent and a request takes the next jump maxJumps leaves.

Usage

local Feel = require("@builtin::systems.characterController.characterController.movement.feel")

local dx, dz
vx, vz, dx, dz = Feel.walk(vx, vz, wantX, wantZ, 20, 30, dt)

local vy, rise = Feel.launch({ jumpHeight = 1.2, jumpApexTime = 0.4, minJumpHeight = 0.4 }, 9.81, true)
vy, rise = Feel.release(vy, rise, jumpHeld)
local dy
dy, vy, rise = Feel.vertical(vy, dt, rise, 9.81, { fallGravityMultiplier = 1.5, maxFallSpeed = 20 })