stride3d / stride3d/stride

CharacterController.IsGrounded seems buggy

Open
#2,814 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C#
Stars
7.8k
Forks
1.2k
Avg merge
2d 17h
Merged PRs (30d)
49

Description

Release Type: Official Release
Version: 4.2.0.2381
Platform(s): Windows 10

I created a new project from First Person Shooter template and started from adding Jump to PlayerController script:
(the event stuff is outside of the scope, Jump is called from Update)

private void Jump()
{
    if (character.IsGrounded)
    {
        if (isJumping)
        {
            Log.Info("Landed");
            isJumping = false;
        }
        jumpEventListener.TryReceive(out var jumpPressed);
        if (!jumpPressed)
        {
            return;
        }
        var jumpDirection = new Vector3(moveDirection.X, 1, moveDirection.Z);
        jumpDirection.Normalize();

        character.Jump(jumpDirection * JumpHeight);
        isJumping = true;
        Log.Info("Jumping!");
    }
    else Log.Info("In air!");
}

To me it seems like the CharacterController's IsGrounded property is hella bugged since I can just hold Space key and fly up, which obviously shouldn't happen.

To Reproduce
Steps to reproduce the behavior:

  1. Create new project from First Person Template
  2. Extend PlayerController with my method, hook it up to Jump key event from PlayerInput.

Expected behavior
Jump works.

Screenshots
Here's the screenshot of a single short key press result (multiple landings and jumps after it did not happened because of the input):
Image

From what I'm seeing it jumps three times per key stroke, for that it also lands three times because it detects grounded state while being midair.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue from the First Person Template using the PlayerController Jump method and the CharacterController.IsGrounded and Jump calls shown here. Trace when IsGrounded reports true during a jump and compare that with the input event handling. Done means a single key press produces one jump and does not report grounded while the character is airborne.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
game-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.