Giter Site home page Giter Site logo

Comments (5)

Anmol270900 avatar Anmol270900 commented on May 4, 2024

Hi! I am a beginner at Unity and would love to work on this issue. Would be great it's assigned to me.
Thankyou.

from open-project-1.

ciro-unity avatar ciro-unity commented on May 4, 2024

Huh, I thought this had been fixed by Pull Request #16? Is it the same issue? Still happening?

from open-project-1.

LHunor avatar LHunor commented on May 4, 2024

Same issue, #16 solved it partially, but it still happens in some cases.
@Quickz 's solution:

private void OnControllerColliderHit(ControllerColliderHit hit)
    {
        if (isJumping)
        {
            // Making sure the collision is near the top of the head
            float permittedDistance = characterController.radius / 2f;
            float topPositionY = transform.position.y + characterController.height;
            float distance = Mathf.Abs(hit.point.y - topPositionY);

            if (distance <= permittedDistance)
            {
                // Stopping any upwards movement
                // and having the player fall back down

                isJumping = false;
                gravityContributionMultiplier = 1f;

                verticalMovement = 0f;
            }
        }
    }

Everything inside the if statement works well, the problem is with the condition. Releasing the jump button cancels the jump, which results in isJumping = false. Therefore, when the player cancels the jump before the collision and this function fires, the fix to the problem won't be executed. There are also other ways for isJumping to turn false, like when the time defined in jumpInputDuration is exceeded, and it would result in the same behavior.
What I suggested is instead of checking isJumping, we should check whether the character has any upward motion:
if (verticalMovement >= 0)...
Very trivial change, but this way, under any circumstance if the character hits a ceiling, the function would work as intended.

from open-project-1.

FeralPug avatar FeralPug commented on May 4, 2024

Shouldn't the isJumping bool get set to false once you are back on the ground I.e. you are done jumping. Would that solve the problem. I suppose I could explore all of the code relating to the jumping.

from open-project-1.

ciro-unity avatar ciro-unity commented on May 4, 2024

Oh, I see, good catch!! Seems like Quickz sent a quick fix. Let me check if it works.

from open-project-1.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.