JumpPad.md 2.6 KB

Jump Pad Controller

This script provides a fully functional Jump Pad system for use in VRChat worlds. The Jump Pad propels players or objects towards a target with a smooth arc, complete with optional animation and debug logging.

Requires:

  • Animator component (optional but recommended for visual feedback)
  • Colliders for trigger detection

Debug - Type: Boolean

  • Enables or disables debug messages for troubleshooting.

Launch Animation - Type: Animator

  • The Animator used to play a launch animation. If it's left empty, the Animator on the Jump Pad's own GameObject is used, if there is one.
  • Default Parameter Name: isLaunch

Jump Target - Type: Transform

  • Specifies the target point where the Jump Pad propels the player or object.

Self - Type: Transform

  • Where the jump arc starts. If it's left empty, the Jump Pad's own Transform is used.

Arc Time - Type: Float

  • The duration (in seconds) for the arc trajectory.
    • Default Value: 1.2

Walk Limit - Type: Float

  • The restricted walk speed for players during the jump.
    • Default Value: 0.2

Run Limit - Type: Float

  • The restricted run speed for players during the jump.
    • Default Value: 0.4

Strafe Limit - Type: Float

  • The restricted strafe speed for players during the jump.
    • Default Value: 0.2

Usage Instructions:

  1. Attach this script to the Jump Pad GameObject in Unity.
  2. Assign the Jump Target Transform to define the destination of the jump.
  3. (Optional) Assign an Animator component and set the animation parameter name if different from the default.
  4. Configure the Arc Time, Walk Limit, Run Limit, and Strafe Limit as needed.

Script Behavior:

  • When a player or object enters the Jump Pad:
    • Calculates and applies the velocity required to reach the Jump Target, using the world's gravity (and, for players, their gravity strength).
    • Limits the player’s movement for the duration of the jump. Landing back on the pad mid-jump launches again and keeps the limit until the last jump ends.
    • Activates the launch animation (if an Animator is assigned).
  • Every player launches themselves, and every client plays the animation when anyone uses the pad, so nothing needs to be synced.
  • A pickup is launched by its owner (the player holding it, or the last one who did), and is dropped first.
  • Once the jump completes:
    • Restores the player’s movement to default speeds.
    • Deactivates the launch animation.

Debug Mode:

  • Outputs detailed logs to Unity’s console, including calculated velocities and state changes, to assist with testing and fine-tuning.