UGTK cat mascotUGTKengine within an engine Request access

UGTK / Toolkit / Component Module / Jump Component Completed

Component Module — UGTK

Jump Component

Summary

The Jump Component system provides robust management for jump mechanics in Unity, supporting both 2D and 3D environments. It offers advanced control over jump execution, including multiple jumps, jump cooldowns, and dynamic interaction with colliders. The system is designed to be flexible, allowing easy customization and integration into various game architectures.


Content


Modules Dependencies

The Jump Component module requires the following dependencies:

Ensure that these dependencies are correctly imported and configured in your project.

Carried inside the prefabs. These modules are not referenced by the assembly definition - the components are simply already attached to the prefabs this module ships. Remove one of them from the project and the prefab keeps its layout and loses that behaviour, with nothing in the console to say so.

Module Component, and the prefab carrying it
UtilitySystems/CollisionSystem Mn_Collider2DEvents (in JumpGameObject2D), Mn_Collider3DEvents (in JumpGameObject3D)

Setup

To set up the Jump Component system, follow these steps:

General Setup

  1. Add GameObject2D or GameObject3D in yur scene. Be sure that everyone has a Rigidbody and a Collider with a Collision Event class:

  1. Configure Jump Settings:
  2. Adjust the jumpForce, maxJumps, jumpCooldown, (that indicates how much time needs to pass by every jump), jumpDirection (that indicates the direction of the jump) and debugMode. Remember also, of modifying gravityScale of your Rigidbody if needed

  1. (Optional) Add Platform Component:

If you want to add a platform that the player can pass through from one direction but not the other: - (2D) If you want to add a platform that the player can pass through from one direction but not the other, use the Unity's Platform Effector 2D to a 2D collider (enable Used by Effector).

 - (3D) If you want to add a platform that the player can pass through from one direction but not the other, add `Mn_3DPlatformComponent` script to a 3D collider.<br>
 <p align="center">
   <img src="/media/Setup3DPlatformComponent.gif?v=552c57e5" loading="lazy" decoding="async" alt="Setup3 d jump component" width="700"  height="227">
 </p>

How To Use

To use the Jump Component system, interact with the following methods and properties:

  1. Trigger Jump:
     jumpComponent.TriggerJump();

Testing Scene

Open JumpScene in the module's Scene/ folder. It holds a 2D pair on the Canvas and a 3D pair in the world; the demo camera frames the 2D one, so that is the one to press.

What to do, in order:

  1. Enter Play Mode, select 2DJumpComponent and press Trigger Jump. Outside Play Mode the button is disabled: the impulse needs a physics step, and the Rigidbody it is applied to is cached in Awake.
  2. Turn on Debug Mode and jump again. The console prints which force source won, the impulse it computed and the moment the floor is touched again - which is when the jump count resets.
  3. Set the source to ReachReferencePoint and assign a target, then change the object's mass or the project's gravity and repeat.

Step 3 is the one that decides which mode you should be using. A hand-tuned fixed force stops landing where it used to as soon as mass or gravity changes; "reach that point" survives both, because the force is computed from the target rather than typed in.

A word on the reference point. With the source set to ReachReferencePoint and no reference assigned, the jump does not fail: it quietly uses the fixed force instead. The inspector now says so and shows that force, because previously it hid the very number the jump was using. If a jump lands somewhere unexpected, that is the first thing to check.

The 2D object in the shipped scene is currently in exactly that state: the prefab assigns its ReachableJumpPoint, but the scene instance overrides the reference to none, so the demo jumps by the fallback force of 550. The gif above is that fallback jump.


Technical Info

The following are the main scripts and workflow of the Jump Component system. Refer to the UML section for the detailed structure.

Scripts:


© 2026 Marcello De Bonis. All rights reserved

Real dependenciesOpen in the map →

Measured from the repository: code references (asmdef) plus prefab and asset GUIDs. Importing this module alone brings in 2 modules in total.