# Tripod with realistic physics in VR

I am making a simulation for setting up a survey station and tripod. Ideally the simulation would have realistic physics, and a requirement of this would be the ability to move the legs of the tripod so that the top can be level.

Does anyone have any insight on how to do this? The user needs to be able to move 1 or 2 of the legs at a time in order to line the tripod up with a point on the ground, and I don’t want the entire tripod to move when the user moves any of the legs.
I am thinking about using centerOfMass to make the tips of the legs stay on the ground, and hoping to get Configurable Joints to work on each of the legs in relation to the top base of the tripod stand.

Here is what I have currently. The angle of the legs in relation to the top part should be able to increase/decrease without moving the entire tripod.

EDIT: I am using Unity 2020.3.30f1 with Unity XR rig

It’s not a fully accurate solution, but I figured out how to get this done for my purposes. First I made a script that tracks the Transform position on the end of the legs (added child gameObjects to each of the legs because they are extendable/retractable) and calculates the CenterOfMass to make sure the tripod doesn’t topple over, since the Rigidbody is on the parent gameObject. Here is the script for that:

CalculateCenterPoint script

public List<Transform> legs = new List<Transform>();
float totalX = 0f;
float totalY = 0f;
float totalZ = 0f;
float centerX = 0f;
float centerY = 0f;
float centerZ = 0f;
Vector3 center;

// Update is called once per frame
void Update()
{
CalculateCenter();
}

public void CalculateCenter()
{
foreach (Transform leg in legs)
{
totalX += leg.transform.position.x;
totalY += leg.transform.position.y;
totalZ += leg.transform.position.z;
}
centerX = totalX / legs.Count;
centerY = totalY / legs.Count;
centerZ = totalZ / legs.Count;

center = new Vector3(centerX, centerY, centerZ);
}

I assigned this script to an empty gameObject called CalculateCenterPoint and made sure it was in the correct position relative to the end of the legs.

For the rotation of the legs, I ended up using a LookAt Constraint on the top of the leg since this is where the point of rotation would be - I just made sure the pivot point was at the point of rotation and also in the center of this rotation (I had it on one side of the leg’s rotation axis and it made the rotation funky). This took a lot of tweaking to get the rotation right. I had to make sure that the RotationAtRest was 0,0,0 and the object’s rotation in the scene was correct before editing the rotation offsets. I used a WorldUpObject (the top base of the tripod) so the constraint knew where “up” was.

For the LookAt Constraint to work properly, I used a slider to control and limit the movement of the leg rotation. This made it easy because I was able to have the leg LookAt Constraint Source be the Slider’s handle so, as you move the slider, the leg moves with it. You can see it in action here

I hope this helps anyone trying to solve a similar issue! It’s not perfect or ideal but seems to work best for VR development and not having to deal with Grab components.