Beispiel #1
0
    private void OnTriggerEnter(Collider other)
    {
        DiskInteractible disk = other.GetComponent <DiskInteractible>();

        if (disk != null)
        {
            if (sound != null)
            {
                if (sound.clip != null)
                {
                    sound.PlayOneShot(sound.clip);
                }
            }

            if (rMan != null)
            {
                rMan.EndRecording();
            }

            other.transform.parent = null;
            Moveable mov = other.GetComponent <Moveable>();
            mov.grabbed = false;
            Destroy(mov);
            ObjectOutline outline = other.GetComponent <ObjectOutline>();
            outline.outline.SetActive(false);
            Destroy(outline);
            other.transform.position = new Vector3(18.46f, 0.9428f, 3.9864f);
            //other.transform.position = new Vector3(18.97348f, 0.4412f, 4.425594f);
            other.transform.rotation = Quaternion.Euler(180, 0, 0);
            Destroy(disk);
        }
    }
Beispiel #2
0
    void OnEnable()
    {
        PickupType.SetValue(gameObject);
        if (transform.childCount > 0)
        {
            Transform T = transform.Find("Outline");
            if (T != null)
            {
                outline       = T.gameObject;
                objectOutline = outline.GetComponent <ObjectOutline>();
            }
        }

        if (trigger == null)
        {
            var sphereCollider = GetComponent <SphereCollider>();
            if (sphereCollider != null)
            {
                trigger = sphereCollider;
            }
            else
            {
                SphereCollider col = gameObject.AddComponent <SphereCollider>();
                trigger       = col;
                col.isTrigger = true;
                col.radius    = 1;
            }
        }
        if (trigger != null)
        {
            trigger.enabled = true;
        }
        else
        {
            print("You forgot a sphere trigger on object: " + this.gameObject.name);
        }

        if (!InteractionEnabled)
        {
            InteractionEnabled = true;
        }
    }
 // Update is called once per frame
 void Update()
 {
     if (transform.parent != null)
     {
         HandState hand = transform.parent.GetComponent <HandState>();
         if (hand == null)
         {
             if (onDelete)
             {
                 Delete();
             }
         }
         else
         {
             if (onDelete)
             {
                 ObjectOutline outline = transform.GetComponent <ObjectOutline>();
                 if (outline != null)
                 {
                     outline.outline.GetComponent <Renderer>().material = outline.deleteMat;
                     outline.outline.gameObject.SetActive(true);
                 }
             }
             else
             {
                 ObjectOutline outline = transform.GetComponent <ObjectOutline>();
                 if (outline != null)
                 {
                     outline.outline.GetComponent <Renderer>().material = outline.outlineMat;
                     outline.outline.gameObject.SetActive(false);
                 }
             }
         }
     }
     else
     {
         if (onDelete)
         {
             Delete();
         }
     }
 }
Beispiel #4
0
    private void OnCollisionStay(Collision collision)
    {
        collided = collision.gameObject;

        HandState hand = collided.GetComponent <HandState>();

        if (hand != null && !triggered)
        {
            if (hand.isGrabbing && (hand.transform.childCount == 2))
            {
                Rigidbody body = GetComponent <Rigidbody>();
                if (body != null)
                {
                    body.isKinematic = true;
                }

                ObjectOutline outline = GetComponent <ObjectOutline>();
                if (outline != null)
                {
                    outline.outline.SetActive(false);
                }

                if (transform.parent != null)
                {
                    if (transform.parent.GetComponent <HandState>() == null)
                    {
                        originalParent = transform.parent;
                    }
                    else
                    {
                        return;
                    }
                }

                transform.parent = collision.collider.transform;
                triggered        = true;
            }
        }
    }
Beispiel #5
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            RaycastHit hit;
            Ray        forwardRay = Camera.main.ScreenPointToRay(Input.mousePosition);

            if (Physics.Raycast(forwardRay, out hit, Camera.main.farClipPlane))
            {
                OnboardingButton b = hit.collider.GetComponent <OnboardingButton>();

                if (b != null)
                {
                    switch (b.type)
                    {
                    case OnboardingButton.Type.Next:
                        b.onboarding.Next();
                        break;

                    case OnboardingButton.Type.Back:
                        b.onboarding.Back();
                        break;

                    case OnboardingButton.Type.Start:
                        b.onboarding.Starting();
                        break;

                    case OnboardingButton.Type.AcceptConsent:
                        b.onboarding.Consent(true);
                        break;

                    case OnboardingButton.Type.DeclineConsent:
                        b.onboarding.Consent(false);
                        break;

                    default: break;
                    }
                }

                DiskInteractible disk = hit.collider.GetComponent <DiskInteractible>();
                if (disk != null)
                {
                    if (rMan != null)
                    {
                        rMan.EndRecording();
                    }

                    hit.collider.transform.parent = null;
                    Moveable mov = hit.collider.GetComponent <Moveable>();
                    mov.grabbed = false;
                    Destroy(mov);
                    ObjectOutline outline = hit.collider.GetComponent <ObjectOutline>();
                    outline.outline.SetActive(false);
                    Destroy(outline);
                    hit.collider.transform.position = new Vector3(18.97348f, 0.4412f, 4.425594f);
                    hit.collider.transform.rotation = Quaternion.Euler(180, 0, 0);
                    Destroy(disk);
                }
            }
        }
    }
Beispiel #6
0
    // Update is called once per frame
    void Update()
    {
        pressing = isRight ? OVRInput.Get(OVRInput.RawButton.RIndexTrigger) : OVRInput.Get(OVRInput.RawButton.LIndexTrigger);//OVRInput.Get(OVRInput.Button.One);

        if (!pressing)
        {
            trigger = false;
        }

        if (interactChild)
        {
            if (!pressing)//(!OVRInput.Get(OVRInput.Button.One))
            {
                if (interactChild.parent.GetComponent <HandInteract>() == null)
                {
                    interactChild.parent = originalParent;

                    Rigidbody body = interactChild.GetComponent <Rigidbody>();
                    if (body != null)
                    {
                        body.isKinematic = false;
                    }
                }

                if (transform.position.y < 0.8)
                {
                    DeleteInteractible(interactChild);
                }

                interactChild = null;
            }

            if (trigger)
            {
                interactChild.parent = transform;
            }

            ObjectOutline objOutline = null;

            if (interactChild)
            {
                objOutline = interactChild.GetComponent <ObjectOutline>();
            }

            if (pressing)//(OVRInput.Get(OVRInput.Button.One))
            {
                if (objOutline)
                {
                    if (transform.position.y < 0.8)
                    {
                        objOutline.outline.GetComponent <Renderer>().material = deleteMat;
                        objOutline.outline.SetActive(true);
                    }
                    else
                    {
                        objOutline.outline.GetComponent <Renderer>().material = objOutline.outlineMat;
                        objOutline.outline.SetActive(false);
                    }
                }
            }
        }
    }