I’m Building a City sim game and I have UI buttons thats is Instantiating a Gameobject.
When a player is pressing a another UI button to build a different building I want to destroy the previous buildng that is currently following the mouse.
I have been struggling on this for a while and can’t seem to work it out.
public void buildHouse()
{
Debug.Log(buildings[0]);
ResourceManager.instance.buildCost(200);
Instantiate(buildings[1], new Vector3(Input.mousePosition.x, Input.mousePosition.y, Input.mousePosition.z), Quaternion.Euler(new Vector3(0, 0, 0)));
}
This is the same for different buildings. I’m not sure if I have made myself clear but i want to add a way to replace a building if there is something allready following the mouse and not beeing yet placed.