Exemplo n.º 1
0
    IEnumerator Lerp(Collider collider)
    {
        Debug.LogError("Lerping");
        float t        = 0f;
        float duration = 2f;

        Vector3 startPostition = collider.transform.position;
        Vector3 endPostition   = disc.transform.position;

        Quaternion startRotation = collider.transform.rotation;
        Quaternion endRotation   = disc.transform.rotation;


        while (t < 1)
        {
            t += Time.deltaTime / duration;

            collider.transform.position = Vector3.Lerp(startPostition, endPostition, t);
            collider.transform.rotation = Quaternion.Lerp(startRotation, endRotation, t);

            yield return(null);
        }

        VinylScript    vinylScript    = collider.gameObject.GetComponent <VinylScript>();
        PlaylistScript playlistScript = vinylScript.playlistScript;

        playlistScript.PlaySomething();
    }
    public void AnimateToPlayer(Vector3 vector3)
    {
        vinylScript = VinylGameObject.GetComponent <VinylScript>();
        vinylScript.DisableUI();
        Hashtable hashtable = new Hashtable();

        hashtable.Add("x", vector3.x);
        hashtable.Add("y", vector3.y);
        hashtable.Add("z", vector3.z);
        hashtable.Add("time", animationTime);
        hashtable.Add("oncomplete", "AnimateOnComplete");

        iTween.MoveTo(gameObject, hashtable);

        iTween.RotateTo(gameObject, new Vector3(0, 0, 0), animationTime);
    }
Exemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        switch (handState)
        {
        //If there is no temporary joint and the player is pressing down on the hand trigger with enough pressure (>= 0.5f in this case),
        //we set the held object’s velocity to zero, and create a temporary joint attached to it.
        //We then connect that joint to our AttachPoint (by default, the hand itself)
        //and set the hand state to HOLDING
        case HandState.TOUCH:
            //   Debug.LogWarning(mHandState);

            if (temporaryJoint == null && OVRInput.Get(OVRInput.Axis1D.PrimaryHandTrigger, touchController) >= 0.5f)
            {
                objectHeld.velocity          = Vector3.zero;
                temporaryJoint               = objectHeld.gameObject.AddComponent <FixedJoint>();
                temporaryJoint.connectedBody = attachedPoint;
                handState = HandState.HOLD;

                //if you grab a vinyl, disable its UI, enable follow cube
                if (objectHeld.gameObject.tag == "vinyl")
                {
                    VinylScript vinylScript = objectHeld.gameObject.GetComponent <VinylScript>();
                    vinylScript.DisableUI();
                    vinylScript.spawnedFollowCube.SetActive(true);
                }
            }
            break;

        // If the hand state is already in the HOLDING state,
        //we check that we do have a temporary joint (i.e. that it is not null)
        //and that the player is releasing enough of the trigger (in this case, < 0.5f).
        //If so, we immediately destroy the temporary joint, and set it to null signifying that it is no longer in use.
        //We then throw the object using a throw method (described further below) and set the hand state to EMPTY.

        case HandState.HOLD:
            //    Debug.LogWarning(mHandState);

            //disable line renderer while holding objects
            lineRenderer.gameObject.SetActive(false);

            if (temporaryJoint != null && OVRInput.Get(OVRInput.Axis1D.PrimaryHandTrigger, touchController) < 0.5f)
            {
                Object.DestroyImmediate(temporaryJoint);
                temporaryJoint = null;


                //To stop collisions with hands when throwing an object
                gameObject.GetComponent <SphereCollider>().enabled = false;
                bool        isThrown    = throwObject();
                VinylScript vinylScript = objectHeld.gameObject.GetComponent <VinylScript>();

                //if object isn't thrown and its a vinyl then re-enable its UI
                if (!isThrown)
                {
                    if (objectHeld.gameObject.tag == "vinyl")
                    {
                        vinylScript.isThrown = false;
                        vinylScript.EnableUI();
                        vinylScript.FollowArtist();
                        //handState = HandState.EMPTY;
                    }
                }
                else
                {
                    //if vinyl is thrown then despawn followcube
                    Destroy(vinylScript.spawnedFollowCube);
                    vinylScript.isThrown = true;
                    //  vinylScript.spawnedFollowCube.SetActive(false);
                }
                //re enable line renderer when letting go of objects
                lineRenderer.gameObject.SetActive(true);
                gameObject.GetComponent <SphereCollider>().enabled = true;
                handState = HandState.EMPTY;
            }
            else if (objectHeld == null)
            {
                handState = HandState.EMPTY;
                //re enable line renderer when letting go of objects
                lineRenderer.gameObject.SetActive(true);
            }
            velocityOld = OVRInput.GetLocalControllerAngularVelocity(touchController);

            break;
        }
    }