Exemplo n.º 1
0
    void FixedUpdate()
    {
        // Runtime check in case of reset (i.e. update in editor)
        if (!CAVE2.IsWandRegistered(wandID, gameObject))
        {
            Debug.LogWarning("CAVE2WandMocapUpdater: Re-registering ID " + wandID);
            CAVE2.RegisterWandObject(wandID, gameObject);
        }

        if (virtualWand && virtualWand.GetComponent <Rigidbody>())
        {
            transform.localPosition = CAVE2Manager.GetWandPosition(wandID);
            transform.localRotation = CAVE2Manager.GetWandRotation(wandID);
            float timeSinceLastUpdate = CAVE2Manager.GetWandTimeSinceUpdate(wandID);

            // If position and rotation are zero, wand is not tracking, disable drawing and physics
            if (timeSinceLastUpdate > 0.5f && virtualWand.gameObject.activeSelf)
            {
                virtualWand.gameObject.SetActive(false);
            }
            else if (timeSinceLastUpdate < 0.5f && !virtualWand.gameObject.activeSelf)
            {
                virtualWand.gameObject.SetActive(true);
            }
        }
    }