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(); } }
// 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; } }
// 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); } } }