Beispiel #1
0
    private void Interactions()
    {
        if (currentItem && Input.GetAxis("P" + playerNumber + "_Action_Axis") == 1f && Time.time > (lastPickupTime + beforeUseCooldown))
        {
            if (currentItem.Utilisation(transform.rotation.eulerAngles.y, this))
            {
                currentItem = null;
            }
        }
        else if (itemInRange && Time.time > (lastPickupTime + pickupCooldown) && Input.GetAxis("P" + playerNumber + "_Action_Axis") == 1f)
        {
            lastPickupTime = Time.time;
            currentItem    = itemInRange;

            // Remove picked up item from in range, from all players
            foreach (PlayerController pc in _players)
            {
                if (pc.GetItemInRange() == currentItem)
                {
                    pc.SetItemInRange(null);
                }
            }

            // Remove pickup script and light and particles from current item
            ObjectPickUp pk = currentItem.gameObject.GetComponent <ObjectPickUp>();
            Destroy(pk.Light.gameObject);
            Destroy(pk.Particles.gameObject);
            Destroy(pk);

            SoundManager.Instance.PlaySFX("Pickup", SoundManager.DefaultTypes.UseItem);
            animator.SetBool("InRange", true);  // PICKUP ANIMATION
            animator.SetTrigger("UseRT");       // PICKUP ANIMATION

            animator.SetBool("InRange", false); // RESET MULTI CONDITION
        }
    }