Example #1
0
    void PickupThrow()
    {
        if (pickupedObject != null)
        {
            pickupedObject.OnThrow();
            pickupedObject = null;
        }
        else
        {
            Debug.Log("uh");
            RaycastHit hit;
            if (Physics.Raycast(raycastPoint.position, transform.TransformDirection(Vector3.forward), out hit, raycastLength))
            {
                Debug.Log(hit.transform.name);

                pickupedObject = hit.transform.GetComponent <IPickupable>();

                if (pickupedObject != null)
                {
                    Debug.Log("Pickup");
                    hit.transform.GetComponent <IPickupable>().PickUp();
                }
            }

            Debug.DrawRay(raycastPoint.transform.position, transform.TransformDirection(Vector3.forward) * hit.distance,
                          Color.yellow);
        }
    }