help rigidbody

i am making small project in which i am using rigidbody

like balance an object base on mass of an both endobject (object 1,object 2 )
same like LEVER


| |
object 1 object 2

i am updating the value mass of object1 value get update but no effect (form 1.0 to 1.19)
but it is moving at run time

I don’t quite get your objects setup, maybe you can post your code…

wild guesses:
-did you enable any freezePosition in Editor?
-is the Rigidbody set to kinematic?
-mass is within reasonable range all the time? Unity - Scripting API: Rigidbody.mass

i am getting something but the problem i want to calculate mass of object

because when i drop any object on on one of end then i want balance at certain point so, it look real

Hey Marrt thiis my source code

void OnMouseDown()
{

if(s.name==“S1”)
{
condition1=1;
a.rigidbody.useGravity=false;
a.rigidbody.useGravity=true;

}

if(s.name==“S2”)
{
condition2=1;
a.rigidbody.useGravity=false;
a.rigidbody.useGravity=true;

}

}

void Update()
{

if(condition1==1)
{
a.rigidbody.mass=1.23f;
a.rigidbody.angularDrag=0.1f;
a.rigidbody.drag=0.2f;
condition1=0;

}

if(condition2==1 (a.rigidbody.mass==1.23f || a.rigidbody.mass==1.0f))
{
a.rigidbody.mass=1.35f;
a.rigidbody.angularDrag=0.5f;
a.rigidbody.drag=0.4f;
condition2=0;

}
}

}

I am still not sure what exactly you are trying to achieve, i gave it a try, i have no editor at hand, so i did this without syntax check:

//toggles masses of the Object, object names S1 will have low high at start

private bool thisHasLowMass = false; //we just use one bool to toggle mass
private Transform thisTransform;
private Rigidbody thisRigidbody;

private float massLight	= 1.25F;
private float massHeavy	= 1.35F;
private float aDragLight = 0.1F;
private float aDragHeavy = 0.5F;
private float dragLight = 0.2F;
private float dragHeavy = 0.4F;



void Start(){
	//we save the reference to these Components, so the engine doesn't have to check if it is present on each call
	thisTransform = transform;
	thisRigidbody = rigidbody;

	//String compares are generally considered "slow",
	//so we only do it at once Start() and only for one of the 2 objects
	if(thisTransform.name=="S1"){
 		thisHasLowMass = true;
 	}
	thisRigidbody.useGravity=true;
	//initially do one Swap to set the values, therefore S1 will have high mass on start
	SwapMasses();
}

void OnMouseDown(){
//not sure if you want this, check http://docs.unity3d.com/Documentation/ScriptReference/MonoBehaviour.OnMouseDown.html
}

void Update(){	//Consider Fixed Update if you want to add Forces later

	//this should be able to recognize your left mouse click
	if(Input.GetKeyDown("mouse 0")){	//GetKeyDown is only true for one Update() frame
		SwapMasses();
	}
}

//if you want to apply forces (thisRigidbody.AddForce(.. ), do this here
void FixedUpdate(){
}

private void SwapMasses(){
	if(thisHasLowMass){
 		thisRigidbody.mass		= massHeavy;
 		thisRigidbody.angularDrag	= aDragHeavy;
 		thisRigidbody.drag		= dragHeavy;
 	}else{
 		thisRigidbody.mass		= massLight;
 		thisRigidbody.angularDrag	= aDragLight;
 		thisRigidbody.drag		= dragLight;
	}

	thisHasLowMass = !thisHasLowMass;	//toggles this bool
}

Ya marrt i have try some other code by modifing my own script but still one problem

i could not get stable excate position like ----------------------------------------------------- straight way 180 degree

balancing the seesaw (thats the correct name for your construction if i interpreted it right) through exchanging 2 weights through mouseclick is a though challenge.
1108553--41755--$seesaw.jpg

Maybe if you state your goal it would be more obvious what you try to achieve with this arrangement.

if you want to stabilize your seesaw artificially you could use a PID-Contoller that takes:
-the angle difference to 180 as error
-the weight difference between the 2 objects as output
so the weight of the objects would change based on the angle of the seesaw, just tune the parameters right and you will be stable in a few Physic-Frames

hey marrt,

you are right i am still confuse total mass of object so, when i drag any other object at of the end it should get balance on the weight of drag object

-So you are trying to create a game where you have to balance out a seesaw?
-You drag objects on it with your mouse?
-and the goal is to balance it out?

ya marrt

do you also care about the position where the weight is put or is it like a

script your own thing where you check which weights are left and right and balance it out manually if the weight difference is within a certain margin and balance it out using a PID-Controller and Rigidbody.AddTorque

or try this contraption, it allows a small weight-difference and will still even out at 180°:

hey marrt,

it is similar like this only but i want drag the and keep it on the upper arm and i m trying to do with mass of rigidbody

forgot to post my picture:
this contraption could ease the balancing by introducing a small margin where weight difference is neglected:1109511--41808--$Untitled.jpg

ya marrt should force and do calculation of total object

hey marrt, i am also attaching other object(like load) on both the end arm so, want to calculate which over all in combine

hey marrt, i have attach my screen shot

hey, marrt, i have solve that problem now if i drag different object example(200gm, 500gm ) on certain point how should manage the mass so it can be stable at different position

Hi,

would be the same as above just taking distance between the Center of mass of an object and the hinge of the lever

hi,
i am not that must expert in formula