public static void Update(Transform transform, PlatformerCharacterState state, PlatformerCharacterConfig config) { state.hasWallGrab = HasWallGrab(state, config); if (HasJumpReset(state, config)) { state.jumpsRemaining = config.jumpCount; } if (state.jumpRequest == PlatformerJumpRequest.Requested && state.jumpsRemaining > 0) { state.jumpsRemaining = state.jumpsRemaining - 1; state.jumpState.requestedState = MotionPlaybackState.Playing; } else if (state.jumpRequest == PlatformerJumpRequest.None && state.jumpState.currentState == MotionPlaybackState.Playing) { state.jumpState.requestedState = MotionPlaybackState.Stopped; } state.walkForce.direction = WALK_MAP[state.walkRequest]; state.walkForce.factor = config.walkSpeed; CurvedMotionForce.Update(config.jumpConfig, state.jumpState); GravityMotionComp.Update(state.gravityState); if (state.jumpState.currentState == MotionPlaybackState.Playing || state.hasWallGrab) { state.gravityState.curvedForceState.delta = 0; state.gravityState.force.factor = 0; state.gravityState.curvedForceState.currentState = MotionPlaybackState.Stopped; state.gravityState.curvedForceState.requestedState = MotionPlaybackState.Playing; } state.hadWallGrab = state.hasWallGrab; CharacterMotor.Update(transform, state.motorState, config.motorConfig); }
public static void Update(GravityForceState state) { var isBlocked = state.motorState.blocked[MotionDirection.Down]; var wasBlocked = state.motorState.wasBlocked[MotionDirection.Down]; if (!isBlocked && wasBlocked) { state.curvedForceState.delta = 0; state.curvedForceState.requestedState = MotionPlaybackState.Playing; } CurvedMotionForce.Update(instance.config, state.curvedForceState); }