using System.Collections; using System.Collections.Generic; using UnityEngine; public class BallGenerator : MonoBehaviour { public GameObject ball; private void Start() { } private void Update() { if (Input.GetMouseButtonDown(0)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); Debug.Log(LayerMask.NameToLayer("Ball")); if (Physics.Raycast(ray, out var hit, 10f)) { Debug.Log(hit.transform.name); } } } }