private bool placed = false; // Records whether the object has been placed or not public override void OnTriggerWasPressed(InteractionController controller) { if (!placed) { base.OnTriggerWasPressed(controller); } else { controller.GetComponent <ControllerUI>().ToggleCanvas(); if (controller.GetComponentInChildren <Canvas>()) { controller.GetComponentInChildren <Text>().text = description; } } }
private void HandleCarriedObject() { if (objectInHand != null) { Vector3 targetPosition = cameraTransform.position + cameraTransform.forward * actualCarryDistance; Vector3 distanceFromPlayer = cameraTransform.position - objectInHand.transform.position; objectInHand.GetComponent <Rigidbody>().MovePosition(Vector3.Lerp(objectInHand.transform.position, targetPosition, 0.1f)); if (distanceFromPlayer.magnitude > 8f) // || objectInHand.straining) { objectInHand.OnDrop(); objectInHand = null; } } }
public sealed override void Use(InteractionController im) { base.Use(im); ItemManager itemManager = im.GetComponent <ItemManager>(); if (itemManager) { itemManager.Take(this); } else { Debug.LogWarning("Item manager is missing"); } Debug.Log("Took: " + name); OnTake(); }
void Start() { init(); interactionController = (InteractionController)interactionController.GetComponent(typeof(InteractionController)); print("grasp" + interactionController.Grasp); }