How would one make it so that blocks stick to each other?
I made a small building of nothing but cubes, but they sway and the floors, roof, and even the top window frame falls down.
I have a little idea that I am working out. I have it so that if the health of a block falls below a certain amount, it explodes and spawns smaller debrey cubes for 4 secs. This is really all I have so far and it works perfect. but I am getting stumped on how to control the physics of the blocks.
How can I make it so that, the blocks are perfectly straight, and once they are hit, then psychics will apply?
I maybe making no sense lol…
Another example would be, if a structure is made of cubes in a T shape, how do you stop the outside cubes from falling down until “assigned interaction” with them??
Your question is a bit all over the place, but I’ll answer your example and hopefully you can go from there. If you have a standing “T” made out of blocks, and you want the two blocks that make up the left and right sides of the top of the “T”…you would (as you said) need to manipulate their physics. This can be accomplished by adding a rigidbody component to each block. Once the blocks are in position, you would deactivate their rigidbody (so gravity doesn’t work on them) via rigidbody.Sleep();.
public class Block : MonoBehaviour{
private GameObject thisBlock;
private Rigidbody thisRigidBody;
void Awake(){
thisBlock = gameObject; //Stores the block as a variable for later access if needed.
thisRigidBody = GetComponent<Rigidbody>(); //Stores the rigidbody component as a variable for later access if needed.
thisRigidBody.Sleep(); //Stops the block from being affected by gravity or any other force.
}
}
Just a sample script. You would attach this to the block. When the scene starts, the block won’t move.