Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Collider and random flipping issue

Discussion in '2D' started by thomas-waldick, Jul 14, 2015.

  1. thomas-waldick

    thomas-waldick

    Joined:
    Jul 14, 2015
    Posts:
    19
    So in my 2d platformer I have 2 issue. 1. The box I have goes through objects kind of. 2. When moving back and forth on a flat surface, my box flips which it shouldn't. This video should explain a bit better:
     
  2. itzclay36

    itzclay36

    Joined:
    Apr 11, 2015
    Posts:
    25
    When you say you can't click fixed angle because you do need the box to turn - do you mean you need to be able to rotate it, or do you mean you need the physics to still rotate it?

    Because you can still rotate it manually from script with fixed angle on, just not with physics.
     
  3. thomas-waldick

    thomas-waldick

    Joined:
    Jul 14, 2015
    Posts:
    19
    I need the physics to turn it. Its part of the game. I just want it to not rotate when moving sideways
     
  4. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,557
    If you're using BoxCollider2D for each of those 'tiles' then you'll be occasionally catching the corners of one of the boxes causing it to rotate (it's not flipping which is a term usual used to indicate mirroring vertically or horizontally).

    Whilst this may not be what you want, it's what you get from Box2D. This is what the EdgeCollider2D is for to provide a continuous surface composed of edges.

    Still one of the best descriptions out there: http://www.iforce2d.net/b2dtut/ghost-vertices

    I'm not sure of the scale of your objects so the overlap could be tiny if your objects are tiny. Try turning on 'Continuous' collision mode on the 'player' Rigidbody2D component.
     
  5. thomas-waldick

    thomas-waldick

    Joined:
    Jul 14, 2015
    Posts:
    19
    This worked, thanks a ton! Ill test it some more but that seemed to have solved my issue
     
  6. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,557
    Good stuff, glad it worked.