Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Annoying collision(?) issue.

Discussion in 'Physics' started by Deleted User, Sep 20, 2018.

  1. Deleted User

    Deleted User

    Guest

    Hi everyone. This is my first post on the forum so please forgive me if I post in the wrong place or say something silly. So, to the point:

    I have a bit of a problem with collisions (I think) in my project. I recorded a clip to show what it's about, here:


    The thing is, I tried to do colliders very neatly, right to the pixel, but for some reason Unity thinks the radius of it is bigger and that causes my character to jump from the ground and just slightly above the ground too and I don't want that. I can also fling myself up when mashing the jump button when I touch vertical surfaces. (Although I think I know how to fix this particular problem, it's probably a layer thing?) But still, I don't know what to do about that mid-air jump.

    Also, when I walk to the corner, as seen in the video, my character slows down, like he's trying to crouch or something. Also, I have the script that includes crouching but after I assigned the button it doesn't do anything. Of course the correct animation isn't there because that's just a placeholder but my walking speed should decrease when I push the crouch button, and it doesn't.

    I'm almost 100% sure this is such a newbie issue and fixing that is super easy but this is my first real project and I really do want to finish it. And I really don't want to learn coding from scratch (even though I know that would most probably be the best solution to everything), it's not that I hate it, but what matters to me right now is time. I would really appreciate some help. Thank you. :)
     
  2. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,193
    Welcome to the forums,

    For your jumping issue, you'll probably want to post your code. It's hard to know what's going on. However, it seems as though your jumping logic doesn't check whether the player is on the ground prior to initiating the jump, but maybe your ground-checking logic is wrong. For example, if you're doing a CircleCast, maybe your radius is too large, or your starting it from the wrong spot. So, let's see how you're checking whether the player is grounded.

    Sorry, but I can't really see that the character is slowing down. Do you maybe have different physic materials on the colliders, causing some floors to be harder to walk across?
     
  3. PGJ

    PGJ

    Joined:
    Jan 21, 2014
    Posts:
    899
    Have you tried using isTouchingLayers for your ground check? It's usually perfect for that purpose.

    The PlatformEffector is useful for not getting stuck on walls (or being able to jump from them).