Hello
i am trying to instantiate an a cylinder gameobject on a plane that has the coordinates of (0,1,0) using left mouse click, and after clicking left mouseclick on the instantiated cylinder a sphere will appear that is 3 unity on the right.
how can this work?
this is the code of cylinder instantiation :
if(Input.GetMouseButtonDown(0))
{
Camera c = GetComponent<Camera>();
Ray r = c.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if(Physics.Raycast(r, out hit))
{
Transform hitObject = hit.transform;
Capsule.transform.position = new Vector3(hit.point.x, 1.0f, hit.point.z);
Instantiate(cylinder);
} }
thank you