Beispiel #1
0
    void Interact()
    {
        RaycastHit hit;

        if (Physics.Raycast(cam.transform.position, cam.transform.forward, out hit, checkingDistance,
                            maskWithoutPlayer))
        {
            if (hit.collider.GetComponentInParent <ContainerController>())
            {
                ContainerController controller = hit.collider.GetComponentInParent <ContainerController>();
                controller.PickUp();
                controller.transform.parent        = handheldObjectTransform;
                controller.transform.localPosition = Vector3.zero;
                controller.transform.localRotation = Quaternion.Euler(0, 0, 0);
                heldObject = controller.gameObject;
            }
            else if (hit.collider.GetComponentInParent <InteractableObject>())
            {
                if (hit.collider.GetComponentInParent <PressablePlate>() && hit.collider.GetComponentInParent <PressablePlate>().hasContainer)
                {
                    ContainerController controller = hit.collider.GetComponentInChildren <ContainerController>();
                    hit.collider.GetComponentInParent <InteractableObject>().Activate(false);
                    controller.transform.parent        = handheldObjectTransform;
                    controller.transform.localPosition = Vector3.zero;
                    controller.transform.localRotation = Quaternion.Euler(0, 0, 0);
                    heldObject = controller.gameObject;
                    return;
                }

                hit.collider.GetComponentInParent <InteractableObject>().Activate(false);
            }
        }
    }
Beispiel #2
0
 public override void Activate(bool forced)
 {
     if (hasContainer)
     {
         ContainerController controller = GetComponentInChildren <ContainerController>();
         controller.PickUp();
         hasContainer = false;
         isActivated  = false;
     }
 }