small fixes

This commit is contained in:
joonasp
2022-05-16 17:47:54 +03:00
parent 9a104a8bd3
commit 86d16e0cf2
23 changed files with 11245 additions and 9795 deletions

View File

@@ -27,7 +27,6 @@ public class ActionGestureInteraction : MonoBehaviour
{
Debug.LogWarning(action);
Debug.LogWarning(player.GetComponent<PlayerInfo>().GetRightHand());
if (player.GetComponent<PlayerInfo>().GetRightHand() != null)
{
@@ -52,7 +51,13 @@ public class ActionGestureInteraction : MonoBehaviour
}
else
{
Debug.LogWarning("WOODCUTTING ACTION");
GameObject tree = FindTree();
if (tree != null)
{
float distance = Vector3.Distance(transform.position, tree.transform.position);
Debug.LogWarning("TREE FOUND: " + distance);
if (distance < 6f) tree.GetComponent<CuttableTree>().Cut();
}
}
break;
case "VerticalLine":
@@ -101,7 +106,7 @@ public class ActionGestureInteraction : MonoBehaviour
}
else
{
Debug.LogWarning("WOODCUTTING ACTION");
}
break;
}
@@ -172,6 +177,22 @@ public class ActionGestureInteraction : MonoBehaviour
return null;
}
GameObject FindTree()
{
Ray ray = playerCamera.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0));
RaycastHit hit;
LayerMask playerLayerMask = LayerMask.GetMask("Player");
if (Physics.Raycast(ray, out hit, playerLayerMask))
{
if (hit.transform.gameObject.transform.name.StartsWith("Cuttable_Tree_"))
{
return hit.transform.gameObject;
}
}
return null;
}
void ShootProjectile()
{
Ray ray = playerCamera.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0));