Example #1
0
    void Update()
    {
        if (canThrow)
        {
            if (Input.touchCount > 0 && !currentlyTouching)
            {
                currentTouch = Input.GetTouch(0);
                if (currentTouch.phase == TouchPhase.Began)
                {
                    StartSwipe();
                }
            }

            if (usingTouchInput && currentlyTouching)
            {
                currentTouch = Input.GetTouch(0);
                if (currentTouch.phase == TouchPhase.Ended)
                {
                    currentlyTouching = false;
                    ThrowItem();
                }
            }

            if (Input.GetMouseButtonDown(0) && !currentlyTouching)
            {
                StartMouseDrag();
            }

            if (usingMouseInput && currentlyTouching)
            {
                if (Input.GetMouseButtonUp(0))
                {
                    currentlyTouching = false;
                    ThrowItem();
                }
            }

            //TODO if statement to see if object is grabbed and released
            if (rightController.IsGrabButtonPressed())
            {
                Debug.Log("Right Grip Pressed");
                isgrabbed = true;
                autoGrabScript.GetComponent <VRTK.VRTK_ObjectAutoGrab>().enabled = true;
            }

            if (isgrabbed && !rightController.IsGrabButtonPressed())
            {
                Debug.Log("Right Grip Pressed");
                autoGrabScript.GetComponent <VRTK.VRTK_ObjectAutoGrab>().enabled = false;
                isgrabbed = false;
                ThrowItem();
            }
        }
    }
Example #2
0
 // Update is called once per frame
 void Update()
 {
     if (rightController.IsGrabButtonPressed())
     {
         autoGrabScript.GetComponent <VRTK.VRTK_ObjectAutoGrab>().enabled = true;
     }
 }
Example #3
0
 protected virtual void CheckGrab(GameObject interactingObject)
 {
     if (grabOnTouchWhen != AutoInteractions.Never && regrabTimer < Time.time)
     {
         VRTK_InteractGrab interactGrabScript = interactingObject.GetComponentInChildren <VRTK_InteractGrab>();
         if (interactGrabScript != null && (grabOnTouchWhen == AutoInteractions.NoButtonHeld || (grabOnTouchWhen == AutoInteractions.ButtonHeld && interactGrabScript.IsGrabButtonPressed())))
         {
             interactGrabScript.AttemptGrab();
         }
     }
 }
Example #4
0
 // Token: 0x060016C5 RID: 5829 RVA: 0x0007ACAC File Offset: 0x00078EAC
 protected virtual void CheckGrab(GameObject interactingObject)
 {
     if (this.grabOnTouchWhen != VRTK_ObjectTouchAutoInteract.AutoInteractions.Never && this.regrabTimer < Time.time)
     {
         VRTK_InteractGrab component = interactingObject.GetComponent <VRTK_InteractGrab>();
         if (component != null && (this.grabOnTouchWhen == VRTK_ObjectTouchAutoInteract.AutoInteractions.NoButtonHeld || (this.grabOnTouchWhen == VRTK_ObjectTouchAutoInteract.AutoInteractions.ButtonHeld && component.IsGrabButtonPressed())))
         {
             component.AttemptGrab();
         }
     }
 }
Example #5
0
    // Update is called once per frame
    void Update()
    {
//		Debug.Log ("force push is updating");
        timer -= Time.deltaTime;
        Rigidbody rbBeingPointedAt = null;
        Vector3   raydir           = -transform.right;

        if (user.IsUseButtonPressed() && !grabber.IsGrabButtonPressed())
        {
            Vector3 camDir = transform.forward;
            if (Camera.main != null)
            {
                camDir = Camera.main.transform.forward;
            }
            float alignment = Vector3.Dot(raydir, camDir);
            //NS.Lines.MakeArrow (ref line_ray, transform.position, transform.position + raydir*100, color, grabRadius, grabRadius);
            if (alignment > .5f)
            {
                RaycastHit rh = new RaycastHit();
                if (Physics.SphereCast(transform.position - raydir * grabRadius, grabRadius, raydir, out rh))
                {
                    //			NS.Lines.MakeCircle (ref line_hit, rh.point, rh.normal, Color.black, grabRadius);
                    //			telekenisisParticle.transform.position = rh.point;
                    if (timer < 0)
                    {
                        telekenisisParticle.Emit(rh.point, -raydir * 1, 1, 1, color);
                    }
                    rbBeingPointedAt = rh.collider.GetComponent <Rigidbody> ();
                    if (rbBeingPointedAt == null)
                    {
                        rbBeingPointedAt = rh.collider.GetComponentInParent <Rigidbody> ();
                    }
                }
            }
        }
        if (rbBeingPointedAt != rbBeingMovedWithTheForce)
        {
            if (rbBeingMovedWithTheForce != null)
            {
                if (hadGravity)
                {
                    rbBeingMovedWithTheForce.useGravity = true;
                }
                rbBeingMovedWithTheForce = null;
            }
            if (rbBeingPointedAt == null)
            {
                Debug.Log("Stopped acting on " + rbBeingMovedWithTheForce);
            }
            rbBeingMovedWithTheForce = rbBeingPointedAt;
            if (rbBeingMovedWithTheForce != null)
            {
                hadGravity = rbBeingMovedWithTheForce.useGravity;
                rbBeingMovedWithTheForce.useGravity = false;
                Debug.Log("Acting on " + rbBeingMovedWithTheForce);
            }
        }
        float speed = 1;

        if (rbBeingMovedWithTheForce != null)
        {
            //NS.Lines.MakeArrow (ref line_ray, transform.position, rbBeingMovedWithTheForce.transform.position, Color.cyan);
//			NS.Lines.MakeCircle(ref line_target, acting.transform.position, raydir, color, grabRadius);
            //telekenisisParticle.transform.position = rbBeingMovedWithTheForce.transform.position;
            Vector3 delta = transform.position - rbBeingMovedWithTheForce.position;
            float   dist  = delta.magnitude;
            //Vector3 dir = delta / dist;
            if (dist > 1)
            {
                speed = dist;
            }
            Vector3 idealV = -raydir * speed;
            Vector3 accel  = idealV - rbBeingMovedWithTheForce.velocity;
            rbBeingMovedWithTheForce.velocity += accel.normalized * grabForce * Time.deltaTime;
            if (timer < 0)
            {
                telekenisisParticle.Emit(transform.position, raydir * speed, 1, 1, color);
            }
        }

        if (timer < 0)
        {
            timer = 1 / 16.0f;
        }
    }