I am trying to do a weighting scale with 2 sides and one side is heavier then other side.It will tilt.How do I set a value to my platform and check the weight
You can create a Script lets say. WeightManager.cs. Keep variable in it: say
*float myWeight = 50.0f; //*some default value
Assign it to both game objects. When need to compare access WeightManager Component/Script of both access myWeight variable…
Simple as that.
so 2 gameobject with the same script and how about the checking of which is heavier
SImplest Method, From your Main Script for comparing:
[SerializableField]
GameObject obj_1; //attach obj 1 here
[SerializableField]
GameObject obj_2; //attach obj 1 here, in editor
void Compare()
{
WeightManager wMgr_1 = obj1.GetCoponent<WeightManager>();
WeightManager wMgr_2 = obj1.GetCoponent<WeightManager>();
if(wMgr_1.myWeight == wMgr_2.myWeight)
{
Debug.log("Same Weight");
}
}
my 2 gameobject is from the same model although i can attach the different parts of the model as the gameobject. What does my weightmanager contains,only a float value?
Yes. WeightManager will only have single variable for now bcoz its the property of that weight.
But there is 2 sides
Seems like you should go with this link gain some knowledge before working on actual game.
Now I understand but it is not checking the weight.Should I attach a weight to my character too to make it work as although my character is standing on one side of the platform but the debug.log shows same weight.I have attach rigid body and box collider to it