I’m using this joystick and Mirror for networking
What I wanted is to detect the gameobject Joystick which is the child of Canvass using Raycast
I’ve tried this script
public class ShootBullet : NetworkBehaviour
{
[SerializeField]
private GameObject bulletPrefab;
private GameObject bullet;
// Set via the Inspector in Units/second
[SerializeField] private float _moveSpeed = 2f;
[SerializeField] private Camera _camera;
Vector3 touch_Pos = new Vector3(0, 0, 0);
private void Awake()
{
if (!_camera) _camera = Camera.main;
}
void Update()
{
if (Input.touchCount > 0 && this.isLocalPlayer)
{
Ray ray = _camera.ScreenPointToRay(Input.GetTouch(0).position);
RaycastHit hit;
if (Physics.Raycast(ray, out hit))
{
if (hit.collider != null)
{
Debug.Log(hit.collider.gameObject.name);
}
}
}
}
}
But it doesn’t work