void Update() { if (Input.GetMouseButtonDown(0)) { Vector3 screenCenter = new Vector3(Screen.width/2, Screen.height/2, 0); Ray ray = _camera.ScreenPointToRay(screenCenter); RaycastHit hit;
if (Physics.Raycast(ray, out hit)) { GameObject hitObject = hit.transform.gameObject; ReactiveTarget target = hitObject.GetComponent<ReactiveTargeet>();
{
_camera = GetComponent<();
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
}
void Update()
{
if (Input.GetMouseButtonDown(0))
{
Vector3 screenCenter = new Vector3(Screen.width/2, Screen.height/2, 0);
Ray ray = _camera.ScreenPointToRay(screenCenter);
RaycastHit hit;
if (Physics.Raycast(ray, out hit))
{
GameObject hitObject = hit.transform.gameObject;
ReactiveTarget target = hitObject.GetComponent<ReactiveTargeet>();
if (target != null)
{
target.ReactToHit();
}
else
{
StartCoroutine (SphereIndicatorCoroutine(hit.point));
Debug.DrawLine(this.transform.position, hit.point, Color.green , 6);
}
}
}
}
void OnGUI()
{
int size = 12;
float posX = _camera.pixelWidth / 2 - size / 4;
float posY = _camera.pixelHeight / 2 - size / 2;
GUI.Label(new Rect(posX, posY, size, size), "*");
}
IEnumerator SphereIndicatorCoroutine (Vector3 targetPosition);
{
// Здесь должна быть реализация корутины
yield return null;
}