- Home /
Question by
RamboPanda · Jul 26, 2011 at 02:52 AM ·
floatcubeswim
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 :)
Comment
You should explain the situation more. I can only assume what you mean by "cubes in a pool".
Answer by mohanrao164 · Aug 04, 2011 at 10:14 AM
try like this
components--->physics--->rigidbody---->constraints
freeze rotation and position.
if they collide also they will not move.