Builtin Library
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 (acceleration20,braking30,jumpForce5,jumpHeight0,jumpApexTime0,minJumpHeight0,fallGravityMultiplier1,maxFallSpeed0).Feel.walk(vx, vz, wantX, wantZ, acceleration, braking, dt) -> (vx, vz, dx, dz): the ground velocity afterdtseconds of walking toward the request, and the distance covered across the ground over them, exact for that motion. It speeds up along the request atacceleration, slows atbraking, sheds the part across the request atbraking, 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, fromjumpForce,jumpHeight,jumpApexTimeandminJumpHeight, against the gravitypull(m/s², positive pulling down).heldsays 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 outminJumpHeightabove 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 atpull * fallGravityMultiplier, no faster thanmaxFallSpeed. 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 jumpmaxJumpsleaves.
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 })