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 not working

Discussion in '2D' started by ghostbuster96, Aug 29, 2015.

  1. ghostbuster96

    ghostbuster96

    Joined:
    Feb 28, 2015
    Posts:
    17
    Hi,
    This is my first post in unity forums, I'm not a mainstream programmer, but I was trying to code something in 2D the other day and the colliders in the scene wont work as they're supposed to.
    what I want to do is,
    When I swipe in any direction(Up, Down, Right, Left only) the gameobject should move in that direction but in a grid like precision. I want to control the no. of units the object moves in one swipe. So I used a variable for the move limit and one for the size of unit movement. My swipe worked nicely, but when I placed another object with a collider in it's path it won't collide with it, instead it moves through the object to the target position. I tried, transform.Translate, Mathf.Lerp, tranform.position everything but the result is the same.
    Both the objects have 2D colliders and just to be safe I gave both of the, rigidbody2D.
    Please tell me how to solve this or an alternate way to move the object so they collide.

    Thank you in advance
     
  2. vakabaka

    vakabaka

    Joined:
    Jul 21, 2014
    Posts:
    1,153
  3. ghostbuster96

    ghostbuster96

    Joined:
    Feb 28, 2015
    Posts:
    17
  4. ghostbuster96

    ghostbuster96

    Joined:
    Feb 28, 2015
    Posts:
    17
    Sir I tried this, But unfortunately it didn't work. It works at really small distances but fails at a distance of 2 to 3 units. but still thank you and if you have any other suggestions please help
     
  5. tedthebug

    tedthebug

    Joined:
    May 6, 2015
    Posts:
    2,570
    Have you put a debug in to see if it is detecting the collision at all?