UGTK / Toolkit / Component Module / Jump Component Completed
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:
- Generic Component: Provides the base classes and structure for all components.
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
- Add
GameObject2DorGameObject3Din yur scene. Be sure that everyone has aRigidbodyand aColliderwith aCollision Eventclass:
- Configure Jump Settings:
- Adjust the
jumpForce,maxJumps,jumpCooldown, (that indicates how much time needs to pass by every jump),jumpDirection(that indicates the direction of the jump) anddebugMode. Remember also, of modifyinggravityScaleof your Rigidbody if needed
- (Optional) Add
PlatformComponent:
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:
- 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:
- Enter Play Mode, select
2DJumpComponentand 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. - 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.
- 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:
- Mn_JumpComponent: Base abstract class providing core functionality for jump management, including cooldowns, multiple jumps, and collision handling.
- Mn_2DJumpComponent: Derived class that implements 2D-specific jump behavior, working with Rigidbody2D and Collider2D.
- Mn_3DJumpComponent: Derived class that implements 3D-specific jump behavior, working with Rigidbody and Collider.
- Mn_3DPlatformComponent: A component that allows the player to pass through a platform from one direction, but not the other.
© 2026 Marcello De Bonis. All rights reserved
Depends on 2
Used by 1
Measured from the repository: code references (asmdef) plus prefab and asset GUIDs. Importing this module alone brings in 2 modules in total.
UGTKengine within an engine


