Add nudging support#560
Merged
Merged
Conversation
- Push keyboard nudge and plumb settings into the physics env at Start: config applied between Awake and Start (the player app does this on table load) previously only reached the component fields and was lost. - Resolve device ids for axis events from an immutable snapshot owned by NativeInputManager, rebuilt when polling starts; the input callback no longer re-enumerates devices or mutates shared dictionaries off the main thread. - Fix default-keyboard-nudge suppression on the Unity input path: the nudge counter is now snapshotted before each input-system update and evaluated after all callbacks ran, instead of comparing against a stale index from the previous key press. - Defer the suppression check behind the queued switch dispatch for main-thread gamelogic engines, so a graph-driven Nudge() suppresses the default nudge instead of doubling it. - Apply sensor strength once in direct cabinet mode (the reference multiplies it twice, scaling with strength squared — upstream bug). - Compact gain-calibrator samples in place when the buffer fills instead of splitting the segment, keeping the rest-to-rest assumption intact for motion longer than 255 ms. - Preserve plumb state on reconfiguration and emit a release edge when disabling while tilted, so the tilt switch cannot stay stuck closed. - Route plumb tilt through the main thread in simulation-thread mode so switch status and key wires update like in single-threaded mode. - Decode native device names as UTF-8, parse sensor mappings with semicolons in the device id, always clamp to the mapping limit, and cap the pending nudge queues with drop warnings. - Cover strength linearity, single-impulse intent, calibrator compaction and mapping round-trips in tests.
Greptile SummaryThis PR adds cabinet nudging support across input, physics, rendering, and editor tooling. The main changes are:
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (4): Last reviewed commit: "editor: Don't pre-clamp raw value in map..." | Re-trigger Greptile |
The native input plugin now reports device arrivals/removals with a DevicesChanged event. Handle it before the window-focus gate (the cache must not go stale while unfocused), rebuild the device-id snapshot and expose a DevicesChanged event for UI consumers.
Owner
Author
|
Addressed the outside-diff WirePlayer note by applying the same native-polling guard used by SwitchPlayer, so Unity InputSystem wire callbacks are ignored while native polling owns input. |
Add keyboard nudge, plumb tilt and visual nudge property fields to the PhysicsEngine inspector, reconfiguring the engine live on change. Also surface the table's NudgeTime property in the table inspector.
Introduce GetNudgeSettings/ConfigureNudge on PhysicsEngine and GetCabinetInputSettings/ApplyCabinetInputSettings on SimulationThreadComponent so nudge and native-input configuration flow through the shared CabinetInputSettings/CabinetNudgeSettings objects instead of many individual Configure* calls. Unpacking now builds a CabinetNudgeSettings and applies it in one call, and sensor conversion delegates to CabinetNudgeSensorSettings. Native input polling can now be reconciled while Play Mode is already running.
Introduce a TiltBobComponent that acts as the table author's routing point for the tilt switch, owning switch dispatch. The player's cabinet settings decide whether the signal originates from the physics plumb-bob simulation or a real mapped cabinet switch. Move plumb-tilt event dispatch out of PhysicsEngine and route it through the tilt-bob component via the simulation thread. Plumb settings on PhysicsEngine are now hidden and default off; older packages still deserialize them but new packages route tilt through the component plus player cabinet settings. Add shared CabinetInputSettings/CabinetNudgeSettings objects (plus a CabinetInputSettingsAsset wrapper) so the same serializable shape can drive runtime config, player JSON, and editor presets, replacing the per-component nudge configuration path. Auto-add the tilt-bob component on VPX import and drop the plumb fields from the physics engine inspector.
Move plumb-bob damping and tilt-threshold tuning off the shared physics/nudge settings and onto TiltBobComponent, where the values are authored, range-clamped, and normalized via OnValidate. Persist the tuning through a new TiltBobPackable so it survives pack/unpack, and keep the legacy CabinetPlumbSettings fields only for JSON compatibility.
Rename the TiltBobMode.Mapped enum value and its related APIs (UsesMappedInput, DispatchMappedTiltInputToMainThread) to Physical to better describe a real cabinet plumb bob wired into the controller. Add a TiltBobInspector exposing plumb damping and threshold angle, and document nudging and tilt bobs in the creators and developer guides.
The raw value was clamped to [-1,1] before subtracting the center, which distorted the displayed direction for off-center inputs. Use the raw value directly so the graph reflects true input offset.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds the VPE nudge stack: keyboard cabinet motion, plumb tilt simulation, native analog cabinet sensors, visual cabinet movement, and editor tooling for KL25Z/Pinscape calibration.
SimulationThreadComponentinspector.vpe-nudge-3m.mp4