I would like to create a board that tilts and balances depending on what kind of weight is on it, and what edge it’s toward - IE, if a box is on one edge of it tilt towards that direction, unless there is another equal weight on the other end. At the moment I’m messing with joints to see if that will produce the desired effect, and it’s been interesting but not entirely effective. It tends to get wacky when more then one object is on the balance. My goal is to create something like this: Equanimity
You can get good results using rigidbodies and a hinge joint: create a simple cube, add a rigidbody and a hinge joint, then set the parameters like below
If you want to test its behaviour, attach this simple script to the balance:
var colors: Color[] = [Color.red, Color.blue, Color.green, Color.gray, Color.yellow];
private var plane: Plane;
function Start () {
plane = new Plane(Vector3.back, transform.position);
}
function Update () {
if (Input.GetButtonDown("Fire1")){
var ray: Ray = Camera.main.ScreenPointToRay(Input.mousePosition);
var dist: float;
if (plane.Raycast(ray, dist)){
var block = GameObject.CreatePrimitive(PrimitiveType.Cube);
block.transform.position = ray.GetPoint(dist);
block.AddComponent(Rigidbody);
block.rigidbody.drag = 1.0;
block.renderer.material.color = colors[Random.Range(0, colors.length)];
}
}
}
