Jump Behavior for CopperCube
A downloadable asset pack
The Jump Behavior extension provides a complete jumping mechanic for a game character in CopperCube. Designed as a standalone behavior, this extension handles the entire jump process—from initial jump input to mid-air movement, double jump execution, and landing detection—by simulating gravity and collision detection. This behavior is ideal for third-person games or any game that requires realistic jump actions.
Important Requirement:
This behavior works only in conjunction with the Collide When Moved behavior. Additionally, the AffectedByGravity parameter in the Collide When Moved behavior must be disabled for this to function correctly.
How It Works
-
Time and Delta Calculation:
The behavior calculates the frame-to-frame time difference (delta) to ensure smooth and consistent jump physics, capping delta values to prevent large frame-time issues. -
Jump Input Detection:
When the spacebar is pressed, the behavior registers the jump input. A jump buffer is used to account for input timing so that the jump or double jump can be registered at the correct moment. -
Jump Logic and Height Adjustment:
-
First Jump: If the character is on the ground and the jump button is pressed, the behavior initiates the first jump, setting a target height based on the configured first jump height.
-
Double Jump: If the character is already in the air (first jump in progress) and the jump button is pressed again, the behavior will trigger a second jump up to the second jump height.
-
-
Gravity and Collision:
The behavior continuously applies gravity to the character’s Y-coordinate to simulate natural falling. It also checks for collisions below the character (to detect if they are on the ground) and collisions above (to determine if the character is hitting their head), adjusting the jump accordingly. -
Action Triggers:
-
An action is triggered when the first jump is executed.
-
A different action is triggered for the second jump if applicable.
-
When the character lands, a landing action is invoked.
This allows developers to tie in custom animations, sounds, or other gameplay events based on the jump stage.
-
-
Collision Parameters Sync:
The collideHeight and collideRelativeHeight parameters in this behavior duplicate the values of the Size and RelativePosition properties from the Collide When Moved behavior. Therefore, it is important that the Collide When Moved behavior is correctly configured, as it influences the collision detection in the jump behavior.
Properties and Their Functionality
-
gravity:
The gravitational factor that pulls the character down.
(Default: 0.1) -
collideHeight:
The height of the area used to detect collisions with the ground or obstacles during a jump.
(Default: 12.0)
(This value is linked to the Size property in the Collide When Moved behavior) -
collideRelativeHeight:
An additional height added to the collision detection area, providing finer control over jump and collision dynamics.
(Default: 3.0)
(This value is linked to the RelativePosition property in the Collide When Moved behavior) -
jumpSpeed:
The speed at which the character ascends during a jump.
(Default: 0.5) -
firstJumpHeight:
The target height achieved on the first jump.
(Default: 20.0) -
secondJumpHeight:
The target height achieved on the second (double) jump.
(Default: 30.0) -
onJumpAction:
An action that is triggered when the first jump is executed. -
onSecondJumpAction:
An action that is triggered when the second jump is executed. -
onLandingAction:
An action that is triggered when the character lands after a jump.
The Jump Behavior extension for CopperCube is a comprehensive solution for implementing jumping mechanics in your games. With support for double jumps, and action triggers at various jump stages, it allows developers to create responsive and dynamic character movement. Whether you're building platformers or action-heavy third-person games, this extension gives you the tools to create immersive jumping experiences with ease.
Updated | 2 days ago |
Published | 4 days ago |
Status | Released |
Category | Assets |
Author | SamGrady |
Tags | ambiera, coppercube, doublejump, gamedev, samgrady |
Code license | MIT License |
Leave a comment
Log in with itch.io to leave a comment.