Exemplo n.º 1
0
    private void DoFullHand()
    {
        RaycastHit snapHit;
        Ray        snapRay = new Ray(cam.transform.position, transform.position - cam.transform.position);

        if (Physics.Raycast(snapRay, out snapHit, 100, snapObjectLayer, QueryTriggerInteraction.Collide))
        {
            var snap = snapHit.collider.GetComponent <SnapPosition>();
            snap.Select();
        }

        // ROTATE OBJECT
        if (Input.GetMouseButtonDown(1))
        {
            pickedObject.transform.Rotate(new Vector3(0, 90, 0));
        }

        // DROP OBJECT
        if (!Input.GetMouseButton(0))
        {
            Vector3 vel = m_Rigidbody.velocity;
            vel.y = 0;

            // DROP NO SNAP
            if (snapHit.collider == null)
            {
                pickedObject.ReleaseObject(Vector3.ClampMagnitude(vel, maxMagnitudeForLaunch));
            }
            // DROP SNAP
            else
            {
                pickedObject.ReleaseObject(snapHit.collider.transform);
            }

            pickedObject = null;

            Vector3 pos = transform.position;
            pos.y = mouseHeight;
            transform.position = pos;
            source.PlayOneShot(pickupSound);

            foreach (var item in snapPos)
            {
                item.HideSnap();
            }
        }
    }