jump mechanic

jump mechanic study in Unreal Engine 4

game engine Unreal Engine 4.19.2
project name StudyJumpMechanic
project template Third Person
project status ongoing
project repo github.com/Arza-3d/UE4-jump-mechanic

This is study project on jump mechanics implementation in Character class in UE4. The study will be done by recreating any jump mechanics in 2 ways:

  1. Pure blueprint : create the jump mechanic inside ActorComponent,
    then this component is attached inside character blueprint.
    This actor components will be created in this folder:
    📁Content/📁BlueprintComponents/📁JumpMechanic/📁ChildClass
  2. Pure C++ : create the jump mechanic directly inside a c++ character class.
    Then create character blueprint from that c++ character class.
    This c++ character classes will be created in this folder:
    📁Source/📁StudyJumpMechanic
note: Epic assets that are used in this project are gitignored.

intro

Currently here is the progress of this project:

  • List of finished jump mechanics :
    • Sprint jump like in Mario Bros or Pepsiman
    • Auto sprint jump like in Unravel
    • Secondary jump like in Tenchu 2
    • Multiple jump like Sanji jump ability in One Piece
    • Jump then glide like Rayman or Spyro
  • List of jump mechanics that are not here yet :
    • Charged jump like in Tony Hawk or any snowboarding game
    • Jump from wall to wall like in Prince of Persia
    • Jump then fast fall
    • Jump on enemy like in Batman Arkham
    • Auto jump like in Assassin's Creed

  • List of extra blueprint component I end up making during this study :

  • List of solved failures :
    • Override Landed could make EventOnLanded inside blueprint won't be fired
    • There is NotifyJumpApex in blueprint and C++, no need to make new function for that task
    • Jump function will not be counted if it's called outside character class
    • OnReachJumpApex can't be access outside of character
    • failed to realize action axis inputs are ticking every frame
    • used UPROPERTY for multiple variables, and got error in anim blueprint... should just go 1 variable 1 UPROPERTY
  • List of unsolved failures :
    • Somehow Muriel C++ character example won't use gliding animation...
    • fail to create jump track with spline component

jump mechanics :

Sprint Jump

pure Blueprint   UE4-blueprint-componentJumpMechanic UE4-blueprint-componentSprintJump
pure C++ SprintJumpCharacter.h + SprintJumpCharacter.cpp

Sprint jump : character ability to jump higher when they jump after sprinting. Sprint jump height will be based on character horizontal speed before jump. Horizontal speed and jump z-initial speed have linear relationship.

I think Mario Bros and Pepsiman use this kind of jump mechanic.

pure Blueprint

In pure blueprint this sprint jump mechanic is made inside SprintJump blueprint component, which is the child of JumpMechanic blueprint component.

Below is character example using that component:


example use in video: FengMaoAnimBP_SprintJump + FengMaoCharBP_SprintJump
outside repo dependencies: Paragon: Feng Mao

Implementation example of SprintJump inside character blueprint:

sprint-Jump-Graph

note:

  • make sure SprintJump.MaxJumpZVelocity > JumpZVelocity,
  • make sure SprintJump.MaxSprintSpeed > MaxWalkSpeed.

pure C++

In pure C++, the sprint jump mechanic is in SprintJumpCharacter.cpp, which is the child of third person character C++ template. This jump mechanic require you to add one more action input (ex: Shift ) which is not part of third person template.

class member declaration:

Sprint jump mechanic logic:

add player input Shift in GameInput.ini :

                   +ActionMappings=(ActionName="SecondaryInput",Key=LeftShift,bShift=False,bCtrl=False,bAlt=False,bCmd=False)
                 

Auto Sprint Jump

pure Blueprint   UE4-blueprint-componentJumpMechanic UE4-blueprint-componentSprintJump_auto
pure C++ SprintJump_autoCharacter.h + SprintJump_autoCharacter.cpp

Auto sprint jump : character has no sprint input, so the normal jump will always depended on how fast it walked before the jump. Just like before the horizontal speed and jump z-initial speed have linear relationship.

I think Unravel used this system.

pure Blueprint

In pure blueprint this jump mechanic is made in SprintJump_auto blueprint component, which is the child of JumpMechanic blueprint component.

pure C++

In pure C++, the sprint jump mechanic is in SprintJump_autoCharacter.cpp, which is the child of third person character C++ template.

class member declaration

auto sprint jump logic :

Secondary Jump

pure Blueprint   UE4-blueprint-componentJumpMechanic UE4-blueprint-componentSecondaryJump
pure C++ SecondaryJumpCharacter.h + SecondaryJumpCharacter.cpp

Secondary jump / Heavy Jump : when character has 2 set of jump modes. There are the default jump and the secondary jump (which usually is higher than the default jump)

Rikimaru and Ayame from Tenchu 2 use secondary jump mechanism.

pure Blueprint

In pure blueprint this jump mechanic is made in SecondaryJump blueprint component, which is the child of JumpMechanic blueprint component.

Below is character example using SecondaryJump :


example use in video : KallariAnimBP_SecondaryJump + KallariCharBP_SecondaryJump
outside repo dependencies: Paragon: Kallari

Implementation example of SecondaryJump inside character blueprint:

secondary-Jump-Graph

pure C++

In pure C++, this jump mechanic is in SecondaryJumpCharacter.cpp, which is the child of third person character C++ template. Additional player input is needed, in here I am using Shift.

class member declaration

secondary jump logic :

add player input Shift in GameInput.ini :

                    +ActionMappings=(ActionName="SecondaryInput",Key=LeftShift,bShift=False,bCtrl=False,bAlt=False,bCmd=False)
                  

Jump then Glide

pure Blueprint   UE4-blueprint-componentJumpMechanic UE4-blueprint-componentJumpThenGlide
pure C++ JumpThenGlideCharacter.h + JumpThenGlideCharacter.cpp

Jump then glide: character able to glide in the air after jump. In this jump mechanic, the glide is achieved throu changing GravityScale after character has reached jump apex ( if the player hold the Space key ). GravityScale is changed to smaller value, but still GravityScale > 0, so if you wanna simulate character that jump with parachute that will have long distance fall, don't use this.

I think Rayman and Spyro used this jump mechanic.

pure Blueprint

In pure blueprint this jump mechanic is made in JumpThenGlide blueprint component, which is the child of JumpMechanic blueprint component.

Below is the example of character using JumpThenGlide :


example use in video : MurielAnimBP_GlideJump + MurielCharBP_GlideJump
outside repo dependencies: Paragon: Muriel

Implementation example of JumpThenGlide inside characterBP:

Glide-Jump

pure C++

In pure C++, this jump mechanic is in SprintJumpCharacter.cpp, which is the child of third person character C++ template.

class member declaration:

jump then glide mechanic logic:

MultipleJumps

note : no need to make new class to make multiple jump because it's so easy to make

example use in video : HowitzerAnimBP_MultipleJumps + HowitzerCharBP_MultipleJumps
outside repo dependencies: Paragon: Howitzer

Multiple Jumps : character ability jump in the air, this include double jump, which basically just multiple jump with 2 jumps limit, in the example above it was just JumpMaxCount = 3.