private void OnTriggerEnter(Collider other) { Pickable obj = other.gameObject.GetComponent <Pickable>(); if (obj && obj.canPick() && !ready) //if pickable { Debug.Log("Sticking: " + Time.time); holder.ToggleHoldable(other.gameObject, true); holder.pickUp(transform.position); ready = true; } }
// Update is called once per frame void Update() { if (holding.isHolding) { holding.updatePosition(transform.position + transform.forward + transform.up); } if (Input.GetKeyDown(KeyCode.E) && holding.isHolding) { holding.releaseItem(Camera.main.transform.forward); } else if (Input.GetKeyDown(KeyCode.E) && holding.canPickUp) { holding.pickUp(transform.position + transform.forward); } if (health <= 0) { Debug.Log("you died, rip"); Time.timeScale = 0.0f; } }