Search Unity

No collisions in Unity 2D.

Discussion in '2D' started by HariprasadA, Dec 15, 2017.

  1. HariprasadA

    HariprasadA

    Joined:
    Nov 14, 2017
    Posts:
    39
    I have a scene with two players and both have colliders on them and are on different layers.
    They don't collide with each other. I tried making them on the same layer and also checked Physics menu.
    Still no change . Please help me....
     
  2. ChrisTobiS

    ChrisTobiS

    Joined:
    Jun 15, 2017
    Posts:
    13
    Is it Collider 2D and not just Collider? And is Trigger set to false? You could post a screenshot if this doesn't help.
     
  3. HariprasadA

    HariprasadA

    Joined:
    Nov 14, 2017
    Posts:
    39

    All seems well snip.JPG
     
  4. ChrisTobiS

    ChrisTobiS

    Joined:
    Jun 15, 2017
    Posts:
    13
  5. HariprasadA

    HariprasadA

    Joined:
    Nov 14, 2017
    Posts:
    39
    Still no luck...
     
  6. LiterallyJeff

    LiterallyJeff

    Joined:
    Jan 21, 2015
    Posts:
    2,807
    Check these things:
    • At least one of the colliding objects needs to have a Rigidbody2D set to Simulated
    • Both need a Collider2D not marked as trigger
    • Both need to be on layers that can collide, as per the Physics2D collision matrix
     
  7. HariprasadA

    HariprasadA

    Joined:
    Nov 14, 2017
    Posts:
    39
    Nope...no luck....
     
  8. LiterallyJeff

    LiterallyJeff

    Joined:
    Jan 21, 2015
    Posts:
    2,807
    If you want more help, you'll need to provide more information. Perhaps screenshots for the inspectors for both objects, and your Physics2D collision matrix. In what way are you moving the objects?
     
  9. HariprasadA

    HariprasadA

    Joined:
    Nov 14, 2017
    Posts:
    39
    Moving them using GetAxis.
    For player one
    1.JPG

    Capture.JPG


    Player 2
    2.JPG


    Physics 2D matrix

    123.JPG
     
  10. LiterallyJeff

    LiterallyJeff

    Joined:
    Jan 21, 2015
    Posts:
    2,807
  11. HariprasadA

    HariprasadA

    Joined:
    Nov 14, 2017
    Posts:
    39
    Code (csharp):
    1.  
    2. pos += rot * velocity;
    3. transform.position = pos;
    4.  
    This is how I move my player. Please someone help me out... I am less on the time left.
     
  12. HariprasadA

    HariprasadA

    Joined:
    Nov 14, 2017
    Posts:
    39
    Fixed it!!!
    Rigidbody 2D in dynamic mode with Gravity Scale set to 0.
    Thanks for your time and efforts.
     
    LiterallyJeff likes this.