Example #1
0
    IEnumerator FixOffset()
    {
        while (true)
        {
            if (tag == null)
            {
                tag = VRTracker.instance.getHeadsetTag();
            }
            if (tag != null)
            {
                Vector3 tagRotation    = tag.getOrientation();
                Vector3 cameraRotation = camera.transform.localEulerAngles;
                Vector3 newRotation    = Vector3.zero;
                newRotation.y = tagRotation.y - cameraRotation.y;

                previousOffset    = destinationOffset;
                destinationOffset = Quaternion.Euler(newRotation);
                t = 0;

                Debug.Log("TAG Rotation: " + tagRotation.x + "  " + tagRotation.y + "   " + tagRotation.z);
                Debug.Log("CAMERA Rotation: " + cameraRotation.x + "  " + cameraRotation.y + "   " + cameraRotation.z);
            }
            yield return(new WaitForSeconds(10));
        }
    }
    // Update is called once per frame
    void LateUpdate()
    {
        if (NetIdent != null && !NetIdent.isLocalPlayer)
        {
            return;
        }

        if (tagToFollow == null && VRTracker.instance != null)
        {
            tagToFollow = VRTracker.instance.GetTag(tagTypeToFollow);
        }
        else if (tagToFollow != null)
        {
            if (followPositionX || followPositionY || followPositionZ)
            {
                transform.position = new Vector3(followPositionX ? tagToFollow.transform.position.x : originalPosition.x, followPositionY ? tagToFollow.transform.position.y : originalPosition.y, followPositionZ ? tagToFollow.transform.position.z : originalPosition.z);
            }

            if (followOrientationX || followOrientationY || followOrientationZ)
            {
                Vector3 newRotation = tagToFollow.getOrientation();
                transform.rotation = Quaternion.Euler(followOrientationX ? newRotation.x : originalRotation.x, followOrientationY ? newRotation.y : originalRotation.y, followOrientationZ ? newRotation.z : originalRotation.z);
            }
        }
    }
    IEnumerator FixOffset()
    {
        while (true)
        {
            if (VRTracker.instance != null)
            {
                if (tag == null)
                {
                    tag = VRTracker.instance.getHeadsetTag();
                }
                if (tag != null)
                {
                    Vector3 tagRotation    = tag.getOrientation();
                    Vector3 cameraRotation = camera.transform.localEulerAngles;

                    newRotation.y     = tagRotation.y - cameraRotation.y;
                    previousOffset    = destinationOffset;
                    destinationOffset = Quaternion.Euler(newRotation);
                    t = 0;
                }
                yield return(new WaitForSeconds(5));
            }
            else
            {
                yield return(new WaitForSeconds(0.5f));
            }
        }
    }
Example #4
0
 public void AddTag(VRTrackerTag tag)
 {
     tags.Add(tag);
     if (OnAddTag != null)
     {
         OnAddTag();
     }
 }
Example #5
0
    public void RetrieveNewTag()
    {
        int          index   = VRTracker.instance.tags.Count;
        VRTrackerTag tagTemp = VRTracker.instance.tags[index - 1].GetComponent <VRTrackerTag>();

        vrtrackerTags = VRTracker.instance.tags;
        LookForLocalPlayer();
    }
        private IEnumerator ShowMenu(UIFader fader, VRTrackerTag tag)
        {
            yield return(StartCoroutine(fader.InteruptAndFadeIn()));

            yield return(StartCoroutine(tag.WaitForAssignation()));

            if (tag.IDisAssigned)
            {
                transform.GetComponent <AudioSource> ().Play();
            }
            yield return(StartCoroutine(fader.InteruptAndFadeOut()));
        }
    // Use this for initialization
    void Start()
    {
        shootingScript = GetComponentInChildren <CompleteProject.PlayerShooting>();
        playerHealth   = gameObject.GetComponent <CompleteProject.PlayerHealth>();

        /*if(shootingScript.vrGun != null)
         * {
         *  // Callback for Local layer, not server
         *  shootingScript.vrGun.OnDown += CmdShoot;
         * }*/
        if (VRTracker.instance != null)
        {
            vrGun = VRTracker.instance.getTag(VRTracker.TagType.Gun);
        }

        if (vrGun != null)
        {
            vrGun.OnDown += FireShot;
        }
    }
    // Use this for initialization
    void Start()
    {
        NetIdent = GetComponentsInParent <NetworkIdentity>()[0];
        if (NetIdent != null && !NetIdent.isLocalPlayer)
        {
            return;
        }

        originalPosition = transform.position;
        originalRotation = transform.rotation.eulerAngles;

        if (VRTracker.instance != null)
        {
            tagToFollow = VRTracker.instance.GetTag(tagTypeToFollow);
        }
        else
        {
            Debug.LogError("No VR Tracker script found in current Scene. Import VRTrackeV2 prefab");
        }
    }
Example #9
0
    IEnumerator FixOffset()
    {
        while (true)
        {
            if (VRTracker.instance != null)
            {
                if (tag == null)
                {
                    tag = VRTracker.instance.GetHeadsetTag();
                }
                if (tag != null)
                {
                    Vector3 tagRotation    = UnmultiplyQuaternion(Quaternion.Euler(tag.getOrientation()));
                    Vector3 cameraRotation = UnmultiplyQuaternion(camera.transform.localRotation);
                    newRotation.y = tagRotation.y - cameraRotation.y;


                    float offsetY = Mathf.Abs(destinationOffset.eulerAngles.y - newRotation.y) % 360;
                    offsetY = offsetY > 180.0f ? offsetY - 360 : offsetY;

                    previousOffset = destinationOffset;

                    destinationOffset = Quaternion.Euler(newRotation);
                    if (Mathf.Abs(offsetY) > minOffsetToBLink)
                    {
                        t = timeToReachTarget;
                    }
                    else
                    {
                        t = 0;
                    }
                }
                yield return(new WaitForSeconds(5));
            }
            else
            {
                yield return(new WaitForSeconds(0.5f));
            }
        }
    }
        float effectsDisplayTime = 0.2f;                // The proportion of the timeBetweenBullets that the effects will display for.

        void Awake()
        {
            // Create a layer mask for the Shootable layer.
            shootableMask = LayerMask.GetMask("Shootable");

            // Set up the references.
            gunParticles = GetComponent <ParticleSystem> ();
            gunLine      = GetComponent <LineRenderer> ();
            gunAudio     = GetComponent <AudioSource> ();
            gunLight     = GetComponent <Light> ();
            //faceLight = GetComponentInChildren<Light> ();

            if (VRTracker.instance != null && VRTracker.instance.getTag(VRTracker.TagType.Gun))
            {
                vrGun = VRTracker.instance.getTag(VRTracker.TagType.Gun);
            }
            // Callback for Local layer, not server

            /*if (vrGun)
             * {
             *  vrGun.OnDown += Shoot;
             *  //vrGun.OnUp += ;
             * }*/
        }
Example #11
0
 public void RemoveTag(VRTrackerTag tag)
 {
     tags.Remove(tag);
 }
Example #12
0
 public void AddTag(VRTrackerTag tag)
 {
     tags.Add(tag);
 }