Customise Consent Preferences

We use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.

The cookies that are categorised as "Necessary" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... 

Always Active

Necessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.

No cookies to display.

Functional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.

No cookies to display.

Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.

No cookies to display.

Performance cookies are used to understand and analyse the key performance indexes of the website which helps in delivering a better user experience for the visitors.

No cookies to display.

Advertisement cookies are used to provide visitors with customised advertisements based on the pages you visited previously and to analyse the effectiveness of the ad campaigns.

No cookies to display.

[ad_1]

I’ve seen that lots of people appear to have this concern however I’ve but to search out an precise working resolution – when a rigidbody-based character controller (I am not utilizing Unity’s character controller) strikes down a sloped floor, they are going to bounce/bunny hop on the way in which down as a substitute of staying on the floor. I am constructing a 3d platformer and bumped into this concern – I’ve tried a good quantity of issues however nothing appears to work cleanly. I managed to discover a 2D resolution right here however I can not seem to get it to work cleanly in 3D. Right here is my code:

    void NormalizeSlope()
{
    // Try vertical normalization
    if (isGrounded)
    {
        RaycastHit hit;
        if (Physics.Raycast(floorCheck.place, Vector3.down, out hit, groundCheckDistance))
        {
            if(hit.collider != null && Mathf.Abs(hit.regular.x) > 0.1f)
            {
                // Apply the other drive in opposition to the slope drive
                // You'll need to offer your personal slopeFriction to stabalize motion
                rigidbody.velocity = new Vector3(rigidbody.velocity.x - (hit.regular.x * 0.4f), rigidbody.velocity.y, rigidbody.velocity.z); //change 0.6 to y velocity

                //Transfer Participant up or all the way down to compensate for the slope under them
                Vector3 pos = remodel.place;
                pos.y += -hit.regular.x * Mathf.Abs(rigidbody.velocity.x) * Time.deltaTime * (rigidbody.velocity.x - hit.regular.x > 0 ? 1 : -1);
                remodel.place = pos;
            }
        }
    }
}

With that, I get various outcomes on surfaces with totally different slopes. Additionally, my character jitters. On some slopes, my character even slowly inches their means up the floor. Has anybody else run into this concern? Does anybody have a working resolution for this downside?

[ad_2]

Leave a Reply

Your email address will not be published. Required fields are marked *