VR Height calibration Script Doesn't Work

VR Height calibration Script Doesn’t Work

Here is the script

using UnityEngine;

public class VRCharacterCalibration : MonoBehaviour
    public Transform headTransform; // Head VR Target
    public Transform leftHandTransform; // left Hand VR Target
    public Transform rightHandTransform; // Right Hand VR Target

    public float defaultHeight = 1.75f; // Default player height
    public float defaultArmLength = 0.6f; // Default arm length

    void Start()

    void CalibrateCharacter()
        // Get the initial positions of head and hands
        Vector3 initialHeadPosition = headTransform.position;
        Vector3 initialLeftHandPosition = leftHandTransform.position;
        Vector3 initialRightHandPosition = rightHandTransform.position;

        // Calculate the initial arm length
        float initialArmLength = Vector3.Distance(initialLeftHandPosition, initialRightHandPosition);

        // Calculate the scaling factor for height and arm length
        float heightScaleFactor = defaultHeight / headTransform.localPosition.y;
        float armScaleFactor = defaultArmLength / initialArmLength;

        // Apply scaling to the player
        transform.localScale = new Vector3(heightScaleFactor, heightScaleFactor, heightScaleFactor);

        // Adjust the position of head and hands based on the scaling
        headTransform.localPosition *= heightScaleFactor;
        leftHandTransform.localPosition *= armScaleFactor;
        rightHandTransform.localPosition *= armScaleFactor;