Cubes in pool

I have added cubes in the pool to act as blocks. The player will move between the gaps of the block. But as I add more blocks, they started crashing into each other. I want my blocks to float side by side with each other in the pool without touching each other. But they kept hitting each other and flying out of the pool. I tried reducing the mass but it did not work. What should I do?

This is the script I am currently using:

var waterLevel: float;
var floatHeight: float;
var buoyancyCentreOffset: Vector3;
var bounceDamp: float;



function FixedUpdate () {
	var actionPoint = transform.position + transform.TransformDirection(buoyancyCentreOffset);
	var forceFactor = 1f - ((actionPoint.y - waterLevel) / floatHeight);
	
	if (forceFactor > 0f) {
		var uplift = -Physics.gravity * (forceFactor - rigidbody.velocity.y * bounceDamp);
		rigidbody.AddForceAtPosition(uplift, actionPoint);
	}
}

Thank you :slight_smile:

try like this
components—>physics—>rigidbody---->constraints
freeze rotation and position.
if they collide also they will not move.