protected override void UseObjectInHand()
{
base.UseObjectInHand();
if (playerUW.playerInventory.ObjectInHand != "")
{ //The player is holding something
//Determine what is directly in front of the player via a raycast
//If something is in the way then cancel the drop
Ray ray;
if (playerUW.MouseLookEnabled == true)
{
ray = Camera.main.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0f));
}
else
{
ray = Camera.main.ScreenPointToRay(Input.mousePosition);
}
RaycastHit hit = new RaycastHit();
if (Physics.Raycast(ray, out hit, playerUW.GetUseRange()))
{
if (hit.transform.gameObject.GetComponent <ObjectInteraction>() != null)
{
hit.transform.gameObject.GetComponent <ObjectInteraction>().Use();
}
else
{
playerUW.CursorIcon = playerUW.CursorIconDefault;
playerUW.playerInventory.ObjectInHand = "";
}
}
else
{
playerUW.CursorIcon = playerUW.CursorIconDefault;
playerUW.playerInventory.ObjectInHand = "";
}
}
}