Esempio n. 1
0
    void holdObject()
    {
        Vector3 nextPos = playerCam.transform.position + playerAim.direction * distance;
        Vector3 currPos = objectRaycast.transform.position;

        interact.CrosshairVisible(false);
        gameManager.LockStates(true, true, true, false, 1);

        objectHeld.GetComponent <Rigidbody> ().isKinematic = false;
        objectHeld.GetComponent <Rigidbody> ().useGravity  = false;
        objectHeld.GetComponent <Rigidbody> ().velocity    = (nextPos - currPos) * 10;

        if (!rotSet && isPaper)
        {
            Vector3 rotation = objectRaycast.GetComponent <ExamineItem> ().paperRotation;
            objectRaycast.transform.rotation = Quaternion.LookRotation(nextPos - currPos) * Quaternion.Euler(rotation);
            rotSet = true;
        }
    }
Esempio n. 2
0
    private void TryPickObject()
    {
        StartCoroutine(AntiSpam());

        if (objectRaycast && !objectRaycast.GetComponent <Rigidbody>())
        {
            Debug.LogError("[DragRigidbody] " + objectRaycast.name + " does not contains a Rigidbody component!");
            GrabObject = false;
            return;
        }

        objectHeld = objectRaycast;

        if (enableObjectPull)
        {
            if (!objectHeld.GetComponent <DragDistance> ())
            {
                float dist = Vector3.Distance(transform.position, objectHeld.transform.position);
                if (dist > maxDistanceZoom - 1f)
                {
                    distance = minDistanceZoom + 0.25f;
                }
                else
                {
                    distance = dist;
                }
            }
            else
            {
                distance = objectHeld.GetComponent <DragDistance>().dragDistance;
            }
        }

        objectHeld.GetComponent <Rigidbody> ().useGravity = false;
        if (objectHeld.GetComponent <Rigidbody>().isKinematic)
        {
            objectHeld.GetComponent <Rigidbody>().isKinematic = false;
        }

        if (FreezeRotation)
        {
            objectHeld.GetComponent <Rigidbody> ().freezeRotation = true;
        }
        else
        {
            objectHeld.GetComponent <Rigidbody> ().freezeRotation = false;
        }

        if (fixedHold)
        {
            oldParent = objectHeld.transform.parent;
            objectHeld.transform.SetParent(playerCam.transform);
        }

        if (dragHideWeapon)
        {
            itemSwitcher.FreeHands(true);
        }

        delay.isEnabled = false;
        gameManager.UIPreventOverlap(true);
        gameManager.ShowGrabSprites();
        gameManager.HideSprites(hideType.Examine);
        gameManager.isGrabbed = true;
        interact.CrosshairVisible(false);
        pfunc.zoomEnabled = false;
        GetComponent <ScriptManager>().ScriptEnabledGlobal = false;

        Physics.IgnoreCollision(objectHeld.GetComponent <Collider>(), transform.root.GetComponent <Collider> (), true);
        objectHeld.SendMessage("OnRigidbodyDrag", SendMessageOptions.DontRequireReceiver);

        StartCoroutine(DropDistance());

        isObjectHeld = true;
    }
Esempio n. 3
0
    private void tryPickObject()
    {
        StartCoroutine(AntiSpam());

        objectHeld = objectRaycast;

        if (!(objectHeld.GetComponent <Rigidbody> ()))
        {
            return;
        }

        if (enableObjectPull)
        {
            if (!objectHeld.GetComponent <DragDistance> ())
            {
                float dist = Vector3.Distance(transform.position, objectHeld.transform.position);
                if (dist > maxDistanceZoom - 1f)
                {
                    distance = minDistanceZoom + 0.25f;
                }
                else
                {
                    distance = dist;
                }
            }
            else
            {
                distance = objectHeld.GetComponent <DragDistance>().dragDistance;
            }
        }

        objectHeld.GetComponent <Rigidbody> ().useGravity = false;
        if (objectHeld.GetComponent <Rigidbody>().isKinematic)
        {
            objectHeld.GetComponent <Rigidbody>().isKinematic = false;
        }

        if (FreezeRotation)
        {
            objectHeld.GetComponent <Rigidbody> ().freezeRotation = true;
        }
        else
        {
            objectHeld.GetComponent <Rigidbody> ().freezeRotation = false;
        }

        if (fixedHold)
        {
            oldParent = objectHeld.transform.parent;
            objectHeld.transform.SetParent(Camera.main.transform);
        }

        if (dragHideWeapon)
        {
            itemSwitcher.Ladder(true);
        }

        delay.isEnabled = false;
        gameManager.UIPreventOverlap(true);
        gameManager.ShowGrabSprites();
        gameManager.HideSprites(spriteType.Examine);
        gameManager.isGrabbed = true;
        interact.CrosshairVisible(false);
        pfunc.enabled = false;
        GetComponent <ScriptManager>().SetScriptEnabledGlobal = false;

        Physics.IgnoreCollision(objectHeld.GetComponent <Collider>(), this.transform.root.GetComponent <Collider> (), true);
        objectHeld.SendMessage("OnRigidbodyDrag", SendMessageOptions.DontRequireReceiver);

        isObjectHeld = true;
    }