Esempio n. 1
0
    public void GrabBegin(GameObject parent_anchor, GameObject parent_sticks)
    {
        isGrabbed       = true;
        grabbing_parent = parent_anchor;
        parent_info     = parent_sticks.GetComponent <ChopstickRotateOculus>();
        object_rigid_body.isKinematic = true;
        //object_rigid_body.interpolation


        this.gameObject.layer = 20;



        //set relative position offset
        Vector3 relPos = this.transform.position - grabbing_parent.transform.position;

        relPos = Quaternion.Inverse(grabbing_parent.transform.rotation) * relPos;

        if (this.name.Contains("Sun"))
        {
            grab_offset_pos = Quaternion.Inverse(grabbing_parent.transform.rotation) * (parent_sticks.transform.Find("Left_chR/ClickSpot/SunSpot").transform.position - grabbing_parent.transform.position);
            Debug.Log("Special Sun Grab");
        }
        else
        {
            grab_offset_pos = relPos;
        }

        //set relative rotation offset
        Quaternion relRot = Quaternion.Inverse(grabbing_parent.transform.rotation) * this.transform.rotation;

        grab_offset_rot = relRot;

        if (transform.childCount > 0)
        {
            foreach (GameObject child in children)
            {
                child.layer = 20;
            }
        }

        if (transform.gameObject.name.Contains("Combadge"))
        {
            GameObject.Find("SceneDirector").GetComponent <SceneDirector>().SetTrek();
            AudioSource chirp = transform.gameObject.GetComponent <AudioSource>();
            if (!chirp.isPlaying)
            {
                chirp.Play();
            }
        }

        if (this.GetComponent <Savable>())
        {
            AddObjectToSave();
        }
    }
Esempio n. 2
0
    void OnTriggerEnter(Collider collision)
    {
        ChopstickRotateOculus temp = GameObject.Find("Chopsticks_Right").GetComponent <ChopstickRotateOculus>();

        if (collision.gameObject.GetComponent <Grabbable>() != null && temp.grabbing == false)
        {
            //Debug.Log("Collided with:" + collision.gameObject.name);
            temp.left_target = collision.gameObject.GetComponent <Grabbable>();
        }
    }
    void Start()
    {
        string my_name = name;

        if (my_name.Contains("chR"))
        {
            my_sticks = GameObject.Find("Chopsticks_Right").GetComponent <ChopstickRotateOculus>();
        }
        else if (my_name.Contains("chL"))
        {
            my_sticks = GameObject.Find("Chopsticks_Left").GetComponent <ChopstickRotateOculus>();
        }
    }
Esempio n. 4
0
    private void Start()
    {
        switch (name)
        {
        case "CollisionSphere_Right":
            my_sticks = GameObject.Find("Chopsticks_Right").GetComponent <ChopstickRotateOculus>();
            break;

        case "CollisionSphere_Left":
            my_sticks = GameObject.Find("Chopsticks_Left").GetComponent <ChopstickRotateOculus>();
            break;
        }
    }