Example #1
0
    void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag.Equals("PuzzleCube"))
        {
            puzzleCubeCloseToSlot = other.gameObject;

            puzzleCubeGrabbable        = puzzleCubeCloseToSlot.GetComponent <OVRGrabbable_EventExtension>();
            puzzleCubeAttachableTarget = puzzleCubeCloseToSlot.GetComponent <AttachableTarget>();
        }
    }
Example #2
0
    void OnTriggerExit(Collider other)
    {
        if (other.gameObject.tag.Equals("PuzzleCube") && other.gameObject.Equals(puzzleCubeCloseToSlot))
        {
            puzzleCubeCloseToSlot = null;
            puzzleCubeInSlot      = false;

            if (puzzleCubeAttachableTarget != null)
            {
                puzzleCubeAttachableTarget.allowAttaching = true;
            }

            puzzleCubeGrabbable        = null;
            puzzleCubeAttachableTarget = null;
        }
    }
    public void AttachToObject(GameObject go)
    {
        target = go.GetComponentInParent <AttachableTarget>();
        if (!target.CanBeAttachedTo())
        {
            return;
        }

        target.AttachObject(this);

        transform.position = go.transform.position;
        transform.rotation = go.transform.rotation;

        // myGrabCollider.enabled = false;
        mySolidCollider.enabled = false;
        attachedTo = go;

        GameMaster.instance.tutorialMaster.TileAttached();
    }
    // Start is called before the first frame update
    void Start()
    {
        GameObject resetObjectVolume = GameObject.FindGameObjectWithTag("ResetStartingPoint");

        if (useResetStartingPoint && resetObjectVolume)
        {
            startingPosition = resetObjectVolume.transform.position;
            startingArea     = resetObjectVolume.GetComponent <BoxCollider>();
        }
        else
        {
            startingPosition = transform.position;
        }

        rb                     = GetComponent <Rigidbody>();
        myCollider             = GetComponent <Collider>();
        originalColliderBounds = myCollider.bounds.size;

        grabbableScript        = GetComponent <OVRGrabbable_EventExtension>();
        attachableTargetScript = GetComponent <AttachableTarget>();
        attachableScript       = GetComponent <Attachable>();

        rubiksScript = GetComponent <RotateRubiks>();

        if (renderers.Length > 0)
        {
            materials = new Material[renderers.Length];
            for (int i = 0; i < renderers.Length; i++)
            {
                materials[i] = renderers[i].material;
            }
        }
        else
        {
            materials    = new Material[1];
            materials[0] = GetComponentInChildren <Renderer>().material;
        }

        if (!rb)
        {
            Debug.LogError(gameObject.name + ": Rigidbody was not found!");
        }
        if (!materials[0])
        {
            Debug.LogError(gameObject.name + ": Material was not found!");
        }
        if (!myCollider)
        {
            Debug.LogError(gameObject.name + ": Collider was not found!");
        }
        if (!grabbableScript)
        {
            Debug.LogError(gameObject.name + ": Grabber script was not found!");
        }

        originalScale = transform.localScale;

        if (!resetSoundSource)
        {
            Debug.LogError(gameObject.name + ": Reset sound Audio Source was not found!");
        }
        startingPitch = resetSoundSource.pitch;
        if (!resetOutSound)
        {
            Debug.LogError(gameObject.name + ": Reset OUT sound Audio Clip was not found!");
        }
        if (!resetInSound)
        {
            Debug.LogError(gameObject.name + ": Reset IN sound Audio Clip was not found!");
        }
    }