Search Unity

Question Rigidbody with X and Z frozen, stops falling after colliding with a static body

Discussion in '2D' started by ArthurWesley, Aug 27, 2020.

  1. ArthurWesley

    ArthurWesley

    Joined:
    May 9, 2020
    Posts:
    2
    I seriously couldn't find if this problem was asked somewhere, so I will try to ask here, as my first post on this forum, about this problem that is happening.
    I have a 2d "sand" block which can fall, but can't move X direction. Also, I have a static block, which can't move in any direction. If I place two sand blocks like the image, they manage to fall.




    1.png 2.png
    But if I place it next to a static block, it stops falling, like the picture.

    3.png 4.png

    Here is the piece of code I use to pace the blocks, where I try to "simulate" a 2D grid:
    Code (CSharp):
    1. void PlaceBlock(){
    2.         Vector3 ct = GameObject.Find("Cursor").transform.position;
    3.         block.transform.position = new Vector3(Mathf.Round(ct.x), Mathf.Round(ct.y), (int)ct.z);
    4.         Instantiate(block);
    5.         canPlaceBlock = false;
    6.     }
    Thank you in advance.