Exemplo n.º 1
0
    public void OnInteract(PCameraInteract cameraParentIn)
    {
        CameraParent = cameraParentIn;
        if (!CameraParent)
        {
            return;
        }

        if (InteractType == EInteractType.EHoldable)
        {
            if (!rigidbody || !collider)
            {
                return;
            }
            isBeingHeld = !isBeingHeld;

            if (isBeingHeld && rigidbody && collider)
            {
                rigidbody.isKinematic = true;
                collider.enabled      = false;
            }
            else if (!isBeingHeld)
            {
                rigidbody.isKinematic = false;
                collider.enabled      = true;
            }
        }
        else if (InteractType == EInteractType.EToggleable)
        {
            PerformToggleAction();
        }
    }
Exemplo n.º 2
0
 public void OnSecondaryInteract(PCameraInteract cameraParentIn)
 {
     if (InteractType == EInteractType.EHoldable)
     {
         if (isBeingHeld)
         {
             rigidbody.isKinematic = false;
             collider.enabled      = true;
             isBeingHeld           = false;
             rigidbody.AddForce(cameraParentIn.transform.forward * throwStrength, ForceMode.Impulse);
         }
     }
 }