Ejemplo n.º 1
0
    private void FixedUpdate()
    {
        if (!finishedAnimating)
        {
            if (ikResetTimer > 0)
            {
                ikResetTimer -= Time.deltaTime;
            }
            else
            {
                if (checkedIK == false)
                {
                    playerIK.SetIKLeftStatus(true);
                    checkedIK = true;
                }
                finishedAnimating = true;
            }
        }

        if (!busyAnimating)
        {
            if (playerIK.ikWeightLeft > 0.1f)
            {
                if (checkedIK == false)
                {
                    playerIK.SetIKLeftStatus(true);
                    checkedIK = true;
                }
            }
        }
    }
Ejemplo n.º 2
0
    private void Update()
    {
        Ray ray = cam.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0));

        Vector3 forward = this.transform.TransformDirection(Vector3.forward) * 100;

        RaycastHit hit;

        if (Physics.Raycast(ray, out hit, interactDistance, layer))
        {
            // Set emission
            InteractableObject obj = hit.transform.gameObject.GetComponent <InteractableObject>();

            // If object can be interacted with
            if (obj != null)
            {
                // Make item glow
                obj.highlighted = true;
                obj.Highlight();

                // Enable Player Left Hand IK
                if (playerIK)
                {
                    playerIK.leftIKTargetPos = obj.transform.position;
                    playerIK.SetIKLeftStatus(false);
                }

                if (obj.tag == "Key")
                {
                    if (Input.GetMouseButtonDown(0))
                    {
                        // Play pickup sound
                        obj.GetComponent <AudioSource>().Play();

                        // Add to inventory
                        this.GetComponent <Inventory>().Keys.Add(obj.GetComponent <Key>().KeyID);

                        // Destroy
                        StartCoroutine(DestroyItem(obj.gameObject));
                    }
                }
            }
            else
            {
                if (hit.transform.tag != "Door")
                {
                    playerIK.SetIKLeftStatus(true);
                }
            }

            if (hit.transform.tag == "Door")
            {
                Door door = hit.transform.GetComponent <Door>();

                // Player Left Hand IK
                if (playerIK && door.openedDoor == false && door.busyAnimating == false)
                {
                    playerIK.leftIKTargetPos = hit.transform.position;
                    playerIK.SetIKLeftStatus(false);
                }

                if (Input.GetMouseButtonDown(0) && door.busyAnimating == false)
                {
                    if (door.TargetKeyID == 555)
                    {
                        // Killknock
                        door.GetComponent <KillKnock>().enabled = true;
                    }
                    else
                    {
                        door.Open();
                    }
                }
            }
            else if (hit.transform.tag == "RedBook")
            {
                if (Input.GetMouseButtonDown(0))
                {
                    // Activate book script
                    hit.transform.GetComponent <RedBook>().enabled = true;
                }
            }
            else if (hit.transform.tag == "GhostSpawnTrigger")
            {
                // Spawn ghost
                StartCoroutine(SetGhostActive());
            }
        }
    }