I'm trying to make a instance of a GameObject at the position of the mouse when LeftMouseButton is pressed ,im trying to convert it to world position but i get a error : Member 'Camera.main.current' cannot be accessed with an instance reference; qualify it with a type name instead
public GameObject tower;
public Camera sceneCamera;
Vector3 objectP;
void Update ()
{
sceneCamera = Camera.main;
if (sceneCamera!= null)
{
Vector3 mousePos = Input.mousePosition;
mousePos.z = 2.0f;
Vector3 objectP = Camera.main.current.ScreenToWorldPoint(mousePos);
}
if (Input.GetButtonDown("Fire1"))
{
Instantiate(tower,objectP, Quaternion.identity);
}
}
}