fixed bug with road collider,
added some city environment, just for fun
This commit is contained in:
@@ -35,8 +35,6 @@ public class CameraSystem : MonoBehaviour
|
||||
private float _moveSpeed = 25f;
|
||||
[SerializeField]
|
||||
private int _edgeScrollSize = 20;
|
||||
private bool _dragPanMoveActive = false;
|
||||
private bool _dragRotateMoveActive = false;
|
||||
[SerializeField]
|
||||
private float _dragPanSpeed = 2f;
|
||||
[SerializeField]
|
||||
@@ -55,7 +53,7 @@ public class CameraSystem : MonoBehaviour
|
||||
private void Start()
|
||||
{
|
||||
transform.position = Player.Instance.transform.position;
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
@@ -77,6 +75,11 @@ public class CameraSystem : MonoBehaviour
|
||||
{
|
||||
HandleCameraZoom_MoveY(zoomAmount);
|
||||
}
|
||||
|
||||
if (_useEdgeScrolling)
|
||||
{
|
||||
EdgeScrollingMovement();
|
||||
}
|
||||
//HandleCameraZoom_MoveY();
|
||||
//HandleCameraZoom_FOV();
|
||||
//HandleCameraZoom_MoveForward();
|
||||
@@ -133,15 +136,6 @@ public class CameraSystem : MonoBehaviour
|
||||
|
||||
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;
|
||||
transform.position += moveDir * _moveSpeed * Time.deltaTime;
|
||||
}
|
||||
@@ -167,13 +161,18 @@ public class CameraSystem : MonoBehaviour
|
||||
return inputDir;
|
||||
}
|
||||
|
||||
private Vector3 EdgeScrollingMovement(Vector3 inputDir)
|
||||
private void EdgeScrollingMovement()
|
||||
{
|
||||
if (Input.mousePosition.x < _edgeScrollSize) inputDir.x = -1f;
|
||||
if (Input.mousePosition.y < _edgeScrollSize) inputDir.z = -1f;
|
||||
if (Input.mousePosition.x > Screen.width - _edgeScrollSize) inputDir.x = 1f;
|
||||
if (Input.mousePosition.y > Screen.height - _edgeScrollSize) inputDir.z = 1f;
|
||||
return inputDir;
|
||||
Vector3 inputDir = Vector3.zero;
|
||||
|
||||
var mousePosition = Mouse.current.position.ReadValue();
|
||||
if (mousePosition.x < _edgeScrollSize) inputDir.x = -1f;
|
||||
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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -144,7 +144,7 @@ public partial class @InputActions: IInputActionCollection2, IDisposable
|
||||
""id"": ""9e79ba5a-a365-470f-bd83-9f70fcf1ac4e"",
|
||||
""path"": ""OneModifier"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""processors"": ""InvertVector2"",
|
||||
""groups"": """",
|
||||
""action"": ""Move"",
|
||||
""isComposite"": true,
|
||||
|
||||
@@ -122,7 +122,7 @@
|
||||
"id": "9e79ba5a-a365-470f-bd83-9f70fcf1ac4e",
|
||||
"path": "OneModifier",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"processors": "InvertVector2",
|
||||
"groups": "",
|
||||
"action": "Move",
|
||||
"isComposite": true,
|
||||
|
||||
Reference in New Issue
Block a user