Пример #1
0
    public bool Engage()
    {
        var cast = Physics.BoxCastAll(transform.position, new Vector3(reigeon / 2, reigeon / 2, reigeon / 2), Vector3.up);

        int inColCount = 0;

        Valve.VR.SteamVR_TrackedObject foundObject = null;

        foreach (var other in cast)
        {
            Valve.VR.SteamVR_TrackedObject obj = other.collider.GetComponent <Valve.VR.SteamVR_TrackedObject>();
            if (obj != null)
            {
                foundObject = obj;
                inColCount++;
            }
        }

        if (inColCount == 1 && foundObject != null)
        {
            this.transform.localScale = new Vector3(1, 1, 1);
            obj.Remove(foundObject);
            GetComponent <MeshRenderer>().enabled = false;
            Destroy(foundObject.transform.Find("indicator").gameObject);
            transform.SetParent(foundObject.transform);
            this.transform.localPosition = Vector3.zero;
            return(true);
        }
        //else
        return(false);
    }
Пример #2
0
 private void Calibrate(Transform origin, Valve.VR.SteamVR_TrackedObject trackedObject, Vector3 offset)
 {
     origin.position = -trackedObject.transform.position + offset;
     //origin.rotation = Quaternion.Inverse(trackedObject.transform.rotation);
 }
Пример #3
0
 private void DropdownValueChanged(Dropdown dropdown, Valve.VR.SteamVR_TrackedObject trackedObject)
 {
     trackedObject.index = (Valve.VR.SteamVR_TrackedObject.EIndex)dropdown.value;
 }