Coder Social home page Coder Social logo

Comments (4)

Stevepunk avatar Stevepunk commented on August 20, 2024

To resolve this I added an extra grounded check when encountering a wall:
(assuming that if we're grounded and not moving sideways then we also don't want to move vertically either)

    // These mean we can't progress forward. Either a wall or a slope
    if (HasFlag(CollidedSurface.LeftWall) &&
        _velocity.x < 0 &&
        _collidedNormals[DIRECTION_LEFT] == Vector2.right ||
        HasFlag(CollidedSurface.RightWall) &&
        _velocity.x > 0 &&
        _collidedNormals[DIRECTION_RIGHT] == Vector2.left)
    {
        if (IsGrounded())
        {
            velocity = Vector2.zero;
        }
        else
        {
            _velocity.x = 0;
        }   
    }

This resolved the problem for most speeds, but when travelling at fast speeds with a slow computer I found that I had to increase Environment Check Distance from 0.02f to 0.1f.

On even slower computers it may need to be increased more or there may be a more efficient solution..

from unity-2d-platformer-controller.

llafuente avatar llafuente commented on August 20, 2024

I see you have a fork. Can you please commit an example scene and the fix so We can take look.

from unity-2d-platformer-controller.

cjddmut avatar cjddmut commented on August 20, 2024

Is this when encountering a wall or a steep slope?

Also, given that this is in FixedUpdate then it shouldn't matter if the computer is fast or slow.

from unity-2d-platformer-controller.

pixellykyle avatar pixellykyle commented on August 20, 2024

I've also seen this problem and tried the fix from Mr-Sheen a few posts up. It seems to fix the issue in most cases but if the character hits a vertical wall while running up a slope at too high a speed he'll do a little jump/bounce.

All the slopes in my game are 45 degrees, with all other colliders being perfectly horizontal or vertical.

from unity-2d-platformer-controller.

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.