예제 #1
0
    void OnTriggerExit(Collider other)
    {
        if (other.gameObject.CompareTag("WandController"))
        {
            go = null;
        }

        heldHand = handUsed.none;
    }
예제 #2
0
    void OnTriggerStay(Collider other)
    {
        if (other.gameObject.CompareTag("WandController"))
        {
            go = other.gameObject;

            if (other.gameObject.name == "Controller (left)")
            {
                heldHand = handUsed.left;

                if (other.gameObject.name == "Controller (right)")
                {
                    heldHand = handUsed.both;
                }
            }
            else
            {
                heldHand = handUsed.right;
            }
        }
    }
예제 #3
0
    void Update()
    {
        if (timeLeft > 0)
        {
            timeLeft -= Time.deltaTime;
        }

        if (worn && !held)
        {
            transform.position = headCamera.transform.position;
        }

        if (holdingObject == null && go != null)
        {
            if (controllerIn.GetPressDown(Valve.VR.EVRButtonId.k_EButton_Grip))
            {
                print("Grabbing");
                heldHand = handUsed.left;
                Grab(go);
            }
        }

        else if (holdingObject != null && controllerIn.GetPress(Valve.VR.EVRButtonId.k_EButton_Grip) && timeLeft <= 0)
        {
            timeLeft = timeUpdate;
        }
        else if (holdingObject != null && controllerIn.GetPressUp(Valve.VR.EVRButtonId.k_EButton_Grip))
        {
            LetGo();
        }

        if (!held && transform.parent.position != transform.position && !worn)
        {
            /*if((transform.parent.position - transform.position).magnitude < ResetSnapDistance)
             * {
             *  transform.position = transform.parent.position;
             * } else*/
            {
                transform.position = Vector3.MoveTowards(transform.position, transform.parent.position, 1.0f * Time.deltaTime);
            }
        }

        if (Vector3.Distance(transform.position, headCamera.transform.position) < snapDistance && !worn && !held)
        {
            worn = true;
            LetGo();
            transform.position = headCamera.transform.position;
            OnWear.Invoke();
            print("hat worn");
        }
        else if (Vector3.Distance(transform.position, headCamera.transform.position) > snapDistance || held)
        {
            worn = false;
        }

        if (Vector3.Distance(transform.position, headCamera.transform.position) < wornDistance && held)
        {
            OnWear.Invoke();
        }
        else if (Vector3.Distance(transform.position, headCamera.transform.position) > wornDistance && held)
        {
            UnWear.Invoke();
        }
    }
예제 #4
0
    //unfinished, meant for both hands, now only does left


    void Start()
    {
        held     = false;
        worn     = false;
        heldHand = handUsed.none;
    }