fixed bug with road collider,

added some city environment, just for fun
This commit is contained in:
2023-12-10 23:30:35 +02:00
parent 777b5a99fc
commit 05bf8484f5
6 changed files with 2679 additions and 43 deletions
+10 -4
View File
@@ -12,6 +12,11 @@ public class InGameMouseHandler : MonoBehaviour
[SerializeField]
private WaypointVisual _waypointVisual;
[SerializeField]
private Camera _camera;
private Ray _ray;
public static event EventHandler<OnSelectedObjectChangedEventArgs> OnSelectedObjectChanged;
private BaseInteractableObject _selectedObject;
@@ -27,7 +32,7 @@ public class InGameMouseHandler : MonoBehaviour
InputManager.Instance.PlayerAction.PointClick.performed += ClickToMove;
}
private void ClickToMove(UnityEngine.InputSystem.InputAction.CallbackContext context)
private void ClickToMove(InputAction.CallbackContext context)
{
if (!EventSystem.current.IsPointerOverGameObject())
{
@@ -39,8 +44,9 @@ public class InGameMouseHandler : MonoBehaviour
}
else
{
if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out RaycastHit hit, 100f, _walkableLayerMask))
if (Physics.Raycast(_ray, out RaycastHit hit, 100f, _walkableLayerMask))
{
print($"hit point {hit.point} collider pos {hit.collider.transform.position}");
_waypointVisual.SetWaypoint(hit.point);
Player.Instance.AddTask(new PlayerTasks(Tasks.Move, _waypointVisual));
}
@@ -50,13 +56,13 @@ public class InGameMouseHandler : MonoBehaviour
void Update()
{
var ray = Camera.main.ScreenPointToRay(Mouse.current.position.ReadValue());
_ray = _camera.ScreenPointToRay(Mouse.current.position.ReadValue());
if(EventSystem.current.IsPointerOverGameObject())
{
return;
}
//hide rounded menu
if (Physics.Raycast(ray, out var mouseRaycastHit, 100f, _selectableLayerMask))
if (Physics.Raycast(_ray, out var mouseRaycastHit, 100f, _selectableLayerMask))
{
mouseRaycastHit.transform.TryGetComponent(out _selectedObject);
if (_selectedObject != null)