Hello,
i want to move a gameobject that i selected via a button on the mouse position. But the gameobject shows up in the scene and do not move at all. Here is my Code:
private Turrent turrent;
public void showPrefab(Turrent turrent)
{
this.turrent = turrent;
Instantiate(turrent);
}
}
private void Update()
{
if(turrent!= null)
moveTurrent();
}
public void moveTurrent()
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hitInfo;
if (Physics.Raycast(ray, out hitInfo))
{
turrent.transform.position = hitInfo.point;
Debug.Log(turrent.transform.position);
}
}