Start Unit PLacement
navmesh not working yet
This commit is contained in:
parent
afe60bae57
commit
49c5e6df9f
19 changed files with 40382 additions and 89 deletions
21
Assets/Scripts/UnitPlacement.cs
Normal file
21
Assets/Scripts/UnitPlacement.cs
Normal file
|
@ -0,0 +1,21 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class UnitPlacement : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Camera _camera;
|
||||
private Vector3 lastPosition;
|
||||
[SerializeField] private LayerMask placementLayer;
|
||||
|
||||
public Vector3 MapPosition()
|
||||
{
|
||||
Vector3 mousePos = Input.mousePosition;
|
||||
mousePos.z = _camera.nearClipPlane;
|
||||
Ray ray = _camera.ScreenPointToRay(mousePos);
|
||||
RaycastHit hit;
|
||||
if (Physics.Raycast(ray,out hit, 100, placementLayer))
|
||||
{
|
||||
lastPosition = hit.point;
|
||||
}
|
||||
return lastPosition;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue