Esempio n. 1
0
    void Update()
    {
        m_cam = Camera.main.transform;
        RaycastHit hit;

        //If the player isnt hiding it will restrict player movement when 'e' is pressed
        if(!m_isHiding)
        {
            if(Physics.Raycast(m_cam.position, m_cam.TransformDirection(Vector3.forward), out hit, interactionDistance))
            {
                if(hit.transform.tag == "furniture")
                {
                    if(Input.GetKeyDown("e"))
                    {
                        furnitureScript = hit.transform.GetComponentInChildren<Furniture>();
                        if(furnitureScript.setHider(transform))
                        {
                            m_isHiding = true;
                        }
                        //set player movement restrictions
                    }
                }
            }
        }
        //If the player is hiding, pressing 'e' will release player movement
        else
        {
            if(Input.GetKeyDown("e"))
            {
                stopHiding();
        //				transform.rigidbody.constraints = RigidbodyConstraints.FreezeAll;
                //GetComponent<Rigidbody>().constraints
                furnitureScript.releaseHider();
            }
        }
    }