I have a game with blocks that stack up to form a grid. I've a prefab with a Rigidbody2d and box collider2d which I'm reusing for each block, they get skinned with a different sprite. When some blocks at the bottom get removed, I need the above blocks to fall straight down - but they're moving ever so slightly to the left or right, and I'm getting gaps How can I achieve this? I've set angular drag to 0 and enabled 'fixed angle' but I don't know what else to do!
I wouldn't use physics for this. Use an array to represent the block positions, and move them manually. --Eric
Ha, funny you should say that... I actually did that first (a couple weeks ago) and then since the new 2d stuff came out, I thought it'd be better to do it properly with game objects rather than just doing GUI.Box a lot! Apparently not! I guess I was hoping there'd be something like 'is kinematic' but in one dimension, or a way of locking the x value... Or something. Anyway, thanks for reply!
It is proper to do it with GameObjects, but it would still be a good idea to use an array to represent block positions, and move them manually. --Eric
When I was doing the drawing with GUI.Box it was really easy to fit the grid to the screen size, whatever it was - I just divided the width and height number of blocks I needed in each dimension. Not really sure how this works with game objects - having trouble getting the grid to fill the screen. Do I set the screen res or is it controlled by the camera position? What's easiest?
You could also try using physics and apply a Slider Joint to the boxes.... http://docs.unity3d.com/Documentation/Components/class-SliderJoint2D.html