Exemple #1
0
    void ScaleTargets(float scaleMult)
    {
        // Scale VR Rig up/down to appropriate scale
        transform.localScale = Vector3.one * scaleMult;
        if (setPlayerControllerHeight)
        {
            OVRController.GetComponent <CharacterController>().height = playerScale;
        }

        //parent & reposition ant head once VR rig is scaled
        AntHead.transform.SetParent(AntHeadParent);
        AntHead.transform.localPosition = localPosAntHead;
        AntHead.transform.localRotation = Quaternion.Euler(localRotAntHead);
        AntHead.SetActive(true);


        //Debug.Log("floorHeight: " + floorHeight);
        //Debug.Log("transform.localScale: " + transform.localScale);

        //once all this is done, unfade screen
    }
Exemple #2
0
    void OnScaleChanged(float prevHeightScale = -1)
    {
        if (prevHeightScale == -1)
        {
            prevHeightScale = heightScale;
        }

        // Get current capsule height
        var capsuleHeight = pc.GetComponent <CharacterController>().height;

        // Set new capsule scale
        pc.transform.localScale = heightScale * Vector3.one;

        // Scale happens relative to the centre of the capsule, so after scaling it we need to move it to keep the player's feet on the ground
        var   newPos = pc.transform.localPosition;
        float heightChange;

        if (heightScale > prevHeightScale)
        {
            heightChange = (capsuleHeight * 0.5f * (heightScale - prevHeightScale)) * 1.02f;
        }
        else
        {
            heightChange = (capsuleHeight * 0.5f * (heightScale - prevHeightScale)) * 0.98f;
        }

        newPos.y += heightChange;
        pc.transform.localPosition = newPos;

        // The tracking scale set on the slider is absolute, but the value on the cameraRig is relative to the playercontroller scale.
        // This means we need to scale it first to get the desired value.
        var requiredTrackingScale = trackingAndIPDScale / heightScale;

        camRig.transform.localScale = requiredTrackingScale * Vector3.one;

        pc.Acceleration = initialAcceleration * walkSpeedScale;
    }