image.png
image.png
public Camera mainCamrea;
public float h = 0;
private void Update()
{
if (Input.GetKeyDown(KeyCode.Mouse0))
{
Ray ray = mainCamrea.ScreenPointToRay(Input.mousePosition);
float dis = (h - ray.origin.y) / ray.direction.y;
Vector3 pos = ray.origin + ray.direction * dis;
Clone(pos);
}
}
private void Clone(Vector3 pos)
{
GameObject cl = GameObject.CreatePrimitive(PrimitiveType.Sphere);
cl.transform.position = pos;
}
网友评论