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. Dismiss Notice

2D Colliders won't collide after moving to Unity 5 (Solved)

Discussion in '2D' started by dakoots, Mar 9, 2015.

  1. dakoots

    dakoots

    Joined:
    Mar 9, 2015
    Posts:
    6
    Hey! So, I have a peculiar issue with my game in that the 2D colliders have broken. Before, when the project was in Unity 4, it worked fine, but now they don't work. The issue is that my player won't collide with the walls, which are just sprites with colliders. It's able to collide with anything that has a rigidbody, so long as Is Kinematic is disabled. Additionally, I can only get my player to move if Is Kinematic is disabled, an issue I don't recall having.

    The player movement script is attached below.
     

    Attached Files:

  2. superstyle

    superstyle

    Joined:
    Mar 5, 2015
    Posts:
    14
    I think that OnCollisionEnter2D means that you can walk trough objects you are colliding with. Try deleting that from your script and than try again.
     
  3. dakoots

    dakoots

    Joined:
    Mar 9, 2015
    Posts:
    6
    I only put that so that I could have it log when the player actually managed to collide with an object. Nonetheless, I deleted it and it still does not work.
     
  4. Togglesworlh

    Togglesworlh

    Joined:
    Nov 12, 2013
    Posts:
    40
    If isKinematic is enabled, the character will not react to collisions. Kinematic means you have full control over the object and you'll have to handle any collisions yourself, as well as handling the velocity yourself, etc. That is not what you want, unless I'm misunderstanding something. I think you may be mis-remembering whether or not your object was kinematic?
     
  5. dakoots

    dakoots

    Joined:
    Mar 9, 2015
    Posts:
    6
    My player object has kinematic enabled. I would disable it, but when I do, it stops being able to move. The animations play and everything, but it doesn't go anywhere.
     
  6. Togglesworlh

    Togglesworlh

    Joined:
    Nov 12, 2013
    Posts:
    40
    If it's kinematic it won't move at all with your code. You shouldn't have it enabled at all. Disable it.

    Also I guess it won't move either way because you never define Rigid. I don't know how it's animating at all, either. Unless you forgot to include your Start function in the code you provided?

    Code (csharp):
    1.  
    2. // Use this for initialization
    3. void Start () {
    4.     anim = GetComponent<Animator>();
    5.     Rigid = GetComponent<Rigidbody2D>();
    6. }
    7.  

    EDIT: Ah you set it in the editor don't you.

    ...Take a screenshot of your object in the inspector?
     
    Last edited: Mar 10, 2015
  7. dakoots

    dakoots

    Joined:
    Mar 9, 2015
    Posts:
    6
    Sure thing. I'm on a different computer at the moment, but I will post a screenshot later tonight.
     
  8. dakoots

    dakoots

    Joined:
    Mar 9, 2015
    Posts:
    6
    Alright, here it is.

    EDIT: Also, I would set it to not be kinematic, but when I do that it's unable to move. I don't know why.
     

    Attached Files:

    Last edited: Mar 11, 2015
  9. Togglesworlh

    Togglesworlh

    Joined:
    Nov 12, 2013
    Posts:
    40
    Do you have "Apply root motion" enabled in the Animator? If so, try disabling that. It was causing issues for me when I updated to Unity 5 from 4.6.

    Other than that, I don't really know... Everything looks fine.
     
    TheMax2015 likes this.
  10. TheMax2015

    TheMax2015

    Joined:
    Mar 6, 2015
    Posts:
    12
    I watched this yesterday and this may help with your upgrade issues

     
  11. dakoots

    dakoots

    Joined:
    Mar 9, 2015
    Posts:
    6
    Disabling root motion worked! Thank you so much!
     
    TheMax2015 likes this.
  12. Corum

    Corum

    Joined:
    Jan 28, 2014
    Posts:
    17
    Same problem for me. It happens randomly in same 2D terrain conditions and same elements involved.
    Going to watch the above video in search of a solution.

    CircleCollider2D to EdgeCollider2D;
    isKinematic = false;

    EDIT:
    Static Sprite image. No animations;
    Still waiting for a solution.

    edge_unity5_bug.PNG
     
    Last edited: Mar 14, 2015
  13. GarBenjamin

    GarBenjamin

    Joined:
    Dec 26, 2013
    Posts:
    7,441
    You should probably create a new thread just for your issue because this one has had its title changed to Solved for the OP.
     
    Corum likes this.
  14. Corum

    Corum

    Joined:
    Jan 28, 2014
    Posts:
    17
    Many thanks for pointing out.