Esempio n. 1
0
    private void Update()
    {
        if (pushable == null)
        {
            return;
        }

        if (pushable.GetState() == true)
        {
            // That means this item was picked up by a player
            pushable = null;
        }
        else
        {
            // Do pressure plate stuff
            OnPress();
        }
    }
Esempio n. 2
0
    // Update is called once per frame
    void Update()
    {
        if (target == null)
        {
            return;
        }

        if (pushable.GetState() == true)
        {
            // That means this item was picked up by a player
            target   = null;
            pushable = null;
        }
        else
        {
            target.position += new Vector3(0, 0, 1) * Time.deltaTime;
        }
    }
Esempio n. 3
0
    // Update is called once per frame
    void Update()
    {
        if (canMove == false)
        {
            return;
        }

        // Move
        rigidbody.MovePosition(rigidbody.position + (velocity * moveSpeed * Time.deltaTime));

        // Change direction
        if (velocity.x != 0)
        {
            float direction = velocity.x > 0 ? 180 : 0;
            transform.eulerAngles = new Vector3(0, direction, 0);
        }

        // Interact
        if (Input.GetKeyDown(KeyCode.Mouse0))
        {
            // NOTE:(Nathen) We prioratize pushables over interactables
            // This is so you never get in a situation where you can't pick up something
            // because an NPC trigger is blocking the pushable

            // Check if we can interact with a pushable or an interactable
            if (Pushable != null)
            {
                // If we are currently pushing this Pushable
                if (Pushable.GetState() == true)
                {
                    Pushable.Drop();
                }
                else
                {
                    Pushable.Push();
                }
            }
            else if (selectedInteractable != null)
            {
                selectedInteractable.Interact(this);
            }
        }
    }