Esempio n. 1
0
 // Token: 0x060016C6 RID: 5830 RVA: 0x0007AD00 File Offset: 0x00078F00
 protected virtual void CheckUse(GameObject interactingObject)
 {
     if (this.useOnTouchWhen != VRTK_ObjectTouchAutoInteract.AutoInteractions.Never && this.reuseTimer < Time.time)
     {
         VRTK_InteractUse component = interactingObject.GetComponent <VRTK_InteractUse>();
         if (component != null && (this.useOnTouchWhen == VRTK_ObjectTouchAutoInteract.AutoInteractions.NoButtonHeld || (this.useOnTouchWhen == VRTK_ObjectTouchAutoInteract.AutoInteractions.ButtonHeld && component.IsUseButtonPressed())))
         {
             if (!this.interactableObject.holdButtonToUse && this.interactableObject.IsUsing(null))
             {
                 this.interactableObject.ForceStopInteracting();
                 return;
             }
             component.AttemptUse();
         }
     }
 }
Esempio n. 2
0
 protected virtual void CheckUse(GameObject interactingObject)
 {
     if (useOnTouchWhen != AutoInteractions.Never && reuseTimer < Time.time)
     {
         VRTK_InteractUse interactUseScript = interactingObject.GetComponentInChildren <VRTK_InteractUse>();
         if (interactUseScript != null && (useOnTouchWhen == AutoInteractions.NoButtonHeld || (useOnTouchWhen == AutoInteractions.ButtonHeld && interactUseScript.IsUseButtonPressed())))
         {
             if (!interactableObject.holdButtonToUse && interactableObject.IsUsing())
             {
                 interactableObject.ForceStopInteracting();
             }
             else
             {
                 interactUseScript.AttemptUse();
             }
         }
     }
 }
Esempio n. 3
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;
        }
    }