Нажимаю на пол и вообще куда угодно, но выдает что не столкнулось
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player : MonoBehaviour
{
[SerializeField] Camera _playerCamera;
[SerializeField] RenderUI _render;
private Vector2 _screenCenter = new Vector2(Screen.width / 2, Screen.height / 2);
private void Update()
{
if(Input.GetKeyDown(KeyCode.Mouse0))
{
releaseRay();
}
}
private void releaseRay()
{
Ray ray = _playerCamera.ScreenPointToRay(_screenCenter);
RaycastHit hit;
Physics.Raycast(ray, out hit, 1000f);
if(hit.collider != null)
{
if (hit.collider.GetComponent<Ram>())
{
_render.RenderInfo(hit.collider.GetComponent<Ram>());
}
else if (hit.collider.GetComponent<Processor>())
{
_render.RenderInfo(hit.collider.GetComponent<Processor>());
}
else if (hit.collider.GetComponent<Motherboard>())
{
_render.RenderInfo(hit.collider.GetComponent<Motherboard>());
}
}
else
{
print("не столнулось :(");
}
}
}