fixed bug with road collider,
added some city environment, just for fun
This commit is contained in:
+2650
-19
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -35,8 +35,6 @@ public class CameraSystem : MonoBehaviour
|
|||||||
private float _moveSpeed = 25f;
|
private float _moveSpeed = 25f;
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
private int _edgeScrollSize = 20;
|
private int _edgeScrollSize = 20;
|
||||||
private bool _dragPanMoveActive = false;
|
|
||||||
private bool _dragRotateMoveActive = false;
|
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
private float _dragPanSpeed = 2f;
|
private float _dragPanSpeed = 2f;
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
@@ -55,7 +53,7 @@ public class CameraSystem : MonoBehaviour
|
|||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
transform.position = Player.Instance.transform.position;
|
transform.position = Player.Instance.transform.position;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
@@ -77,6 +75,11 @@ public class CameraSystem : MonoBehaviour
|
|||||||
{
|
{
|
||||||
HandleCameraZoom_MoveY(zoomAmount);
|
HandleCameraZoom_MoveY(zoomAmount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_useEdgeScrolling)
|
||||||
|
{
|
||||||
|
EdgeScrollingMovement();
|
||||||
|
}
|
||||||
//HandleCameraZoom_MoveY();
|
//HandleCameraZoom_MoveY();
|
||||||
//HandleCameraZoom_FOV();
|
//HandleCameraZoom_FOV();
|
||||||
//HandleCameraZoom_MoveForward();
|
//HandleCameraZoom_MoveForward();
|
||||||
@@ -133,15 +136,6 @@ public class CameraSystem : MonoBehaviour
|
|||||||
|
|
||||||
private void HandleCameraMovement(Vector2 inputDir)
|
private void HandleCameraMovement(Vector2 inputDir)
|
||||||
{
|
{
|
||||||
if (_useEdgeScrolling)
|
|
||||||
{
|
|
||||||
inputDir = EdgeScrollingMovement(inputDir);
|
|
||||||
}
|
|
||||||
if (_useMouseDrag)
|
|
||||||
{
|
|
||||||
inputDir = MousePanMovement(inputDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector3 moveDir = transform.forward * inputDir.y + transform.right * inputDir.x;
|
Vector3 moveDir = transform.forward * inputDir.y + transform.right * inputDir.x;
|
||||||
transform.position += moveDir * _moveSpeed * Time.deltaTime;
|
transform.position += moveDir * _moveSpeed * Time.deltaTime;
|
||||||
}
|
}
|
||||||
@@ -167,13 +161,18 @@ public class CameraSystem : MonoBehaviour
|
|||||||
return inputDir;
|
return inputDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Vector3 EdgeScrollingMovement(Vector3 inputDir)
|
private void EdgeScrollingMovement()
|
||||||
{
|
{
|
||||||
if (Input.mousePosition.x < _edgeScrollSize) inputDir.x = -1f;
|
Vector3 inputDir = Vector3.zero;
|
||||||
if (Input.mousePosition.y < _edgeScrollSize) inputDir.z = -1f;
|
|
||||||
if (Input.mousePosition.x > Screen.width - _edgeScrollSize) inputDir.x = 1f;
|
var mousePosition = Mouse.current.position.ReadValue();
|
||||||
if (Input.mousePosition.y > Screen.height - _edgeScrollSize) inputDir.z = 1f;
|
if (mousePosition.x < _edgeScrollSize) inputDir.x = -1f;
|
||||||
return inputDir;
|
if (mousePosition.y < _edgeScrollSize) inputDir.y = -1f;
|
||||||
|
if (mousePosition.x > Screen.width - _edgeScrollSize) inputDir.x = 1f;
|
||||||
|
if (mousePosition.y > Screen.height - _edgeScrollSize) inputDir.y = 1f;
|
||||||
|
|
||||||
|
Vector3 moveDir = transform.forward * inputDir.y + transform.right * inputDir.x;
|
||||||
|
transform.position += moveDir * _moveSpeed * Time.deltaTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnCameraRotate(InputAction.CallbackContext context)
|
private void OnCameraRotate(InputAction.CallbackContext context)
|
||||||
|
|||||||
@@ -12,6 +12,11 @@ public class InGameMouseHandler : MonoBehaviour
|
|||||||
[SerializeField]
|
[SerializeField]
|
||||||
private WaypointVisual _waypointVisual;
|
private WaypointVisual _waypointVisual;
|
||||||
|
|
||||||
|
[SerializeField]
|
||||||
|
private Camera _camera;
|
||||||
|
|
||||||
|
private Ray _ray;
|
||||||
|
|
||||||
public static event EventHandler<OnSelectedObjectChangedEventArgs> OnSelectedObjectChanged;
|
public static event EventHandler<OnSelectedObjectChangedEventArgs> OnSelectedObjectChanged;
|
||||||
|
|
||||||
private BaseInteractableObject _selectedObject;
|
private BaseInteractableObject _selectedObject;
|
||||||
@@ -27,7 +32,7 @@ public class InGameMouseHandler : MonoBehaviour
|
|||||||
InputManager.Instance.PlayerAction.PointClick.performed += ClickToMove;
|
InputManager.Instance.PlayerAction.PointClick.performed += ClickToMove;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ClickToMove(UnityEngine.InputSystem.InputAction.CallbackContext context)
|
private void ClickToMove(InputAction.CallbackContext context)
|
||||||
{
|
{
|
||||||
if (!EventSystem.current.IsPointerOverGameObject())
|
if (!EventSystem.current.IsPointerOverGameObject())
|
||||||
{
|
{
|
||||||
@@ -39,8 +44,9 @@ public class InGameMouseHandler : MonoBehaviour
|
|||||||
}
|
}
|
||||||
else
|
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);
|
_waypointVisual.SetWaypoint(hit.point);
|
||||||
Player.Instance.AddTask(new PlayerTasks(Tasks.Move, _waypointVisual));
|
Player.Instance.AddTask(new PlayerTasks(Tasks.Move, _waypointVisual));
|
||||||
}
|
}
|
||||||
@@ -50,13 +56,13 @@ public class InGameMouseHandler : MonoBehaviour
|
|||||||
|
|
||||||
void Update()
|
void Update()
|
||||||
{
|
{
|
||||||
var ray = Camera.main.ScreenPointToRay(Mouse.current.position.ReadValue());
|
_ray = _camera.ScreenPointToRay(Mouse.current.position.ReadValue());
|
||||||
if(EventSystem.current.IsPointerOverGameObject())
|
if(EventSystem.current.IsPointerOverGameObject())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//hide rounded menu
|
//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);
|
mouseRaycastHit.transform.TryGetComponent(out _selectedObject);
|
||||||
if (_selectedObject != null)
|
if (_selectedObject != null)
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ public partial class @InputActions: IInputActionCollection2, IDisposable
|
|||||||
""id"": ""9e79ba5a-a365-470f-bd83-9f70fcf1ac4e"",
|
""id"": ""9e79ba5a-a365-470f-bd83-9f70fcf1ac4e"",
|
||||||
""path"": ""OneModifier"",
|
""path"": ""OneModifier"",
|
||||||
""interactions"": """",
|
""interactions"": """",
|
||||||
""processors"": """",
|
""processors"": ""InvertVector2"",
|
||||||
""groups"": """",
|
""groups"": """",
|
||||||
""action"": ""Move"",
|
""action"": ""Move"",
|
||||||
""isComposite"": true,
|
""isComposite"": true,
|
||||||
|
|||||||
@@ -122,7 +122,7 @@
|
|||||||
"id": "9e79ba5a-a365-470f-bd83-9f70fcf1ac4e",
|
"id": "9e79ba5a-a365-470f-bd83-9f70fcf1ac4e",
|
||||||
"path": "OneModifier",
|
"path": "OneModifier",
|
||||||
"interactions": "",
|
"interactions": "",
|
||||||
"processors": "",
|
"processors": "InvertVector2",
|
||||||
"groups": "",
|
"groups": "",
|
||||||
"action": "Move",
|
"action": "Move",
|
||||||
"isComposite": true,
|
"isComposite": true,
|
||||||
|
|||||||
Reference in New Issue
Block a user