Announcement

Collapse
No announcement yet.

Character Jump in C++ (ACharacter::Jump)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Character Jump in C++ (ACharacter::Jump)

    hello guys i'am new to unreal C++ and trying to understand the character cpp files so i start with the jump functionality and try to track the function calls this what i traced .

    ACharacter::Jump() -----> makes the bPressdJump = true
    and the CheckJumpInput() will increment the jump counts and fire an even OnJumped()

    there are another function called ACharacter::BaseChange() which will call JumpOff function from the character movement class

    so my questions
    1- which class responsible of the jump the character or the character movement component class ??
    2- there are no function or event calls on the Jump() function inside the character !!
    3- is the BaseChange() in the character responsible of the jump and how this function triggered ??

    #2
    Honestly it's been a while since I have delved into the CharacterMovementComponent.

    1) Basically the CharacterMovementComponent is actually responsible for jumping. As you can see the Character "Jump" function only sets the bool that tells the CharacterMovementComponent that it wants to jump. Many of the movement systems work in this fashion. Pawn tells the Movement Component it wants to do something, and the movement component exectues it.

    2) You are correct, there are no event calls on the jump function. That is because the jump function itself is virtual and you can override it. But honestly I never touch the thing, I create a wrapper like "StartJump" or "ExecuteJump" or what ever you want to call it that does the additional logic I want it to do and then if everything is fine I call jump. That said there are Several event functions related to jumping on the Pawn that are called by the MovementComponent such as "OnJumped", "OnLanded", and "OnReachedJumpApex".

    Also when I first started learning UE4 I spent a lot of time in their online documenation for the API, it's not always super clear but looking at the collection of things together can some times help. When looking at specific systems you also have to get a little creative as their can be many variables and functions associated with it, just do Ctrl+Find and you'll find lots of references to "Jump" functions. They also list which ones are virtual, which ones are private, protected, and public, and which ones are inherited overrides from a parent class.

    https://docs.unrealengine.com/en-US/...ter/index.html
    https://docs.unrealengine.com/en-US/...ent/index.html

    3) BaseChange in the MovementComponent is responsible for Changing the "Base" your character is standing on.
    Professional Game Developer
    Asadeus Studios

    Marketplace Content:
    Pro Mounting System

    Comment


      #3
      Thanks ArcainOne for your reply ... i came from a C# background and created a complete game in blueprint without C++ so i like to dig around and study the structure more . unreal provides a really nice templates and complete class like the character and CharacterMovementComponent but it feels like you are stick to their rules so i decided to study the functionality but its a mess .. i will read the API as you said and practice

      Comment

      Working...
      X