Alright, so I've been building a small thing in Unity 2D, and it works for the most part, however whenever I attempt to create a script to spawn a copy of the circle prefab, it just doesn't spawn without any error messages.
I've attempted to use Instantiate to spawn them at the button's location, yet no luck.
{
public GameObject circle;
public Transform circlespawn;
private bool touched = false;
void Update()
{
if(touched == true)
{
Instantiate(circle, circlespawn.position, circlespawn.rotation);
touched = false;
}
}
void OnMouseDown()
{
touched = true;
}
}
From BugFinder in the comments, he pointed out I simply needed a collider for the onmousedown to work correctly.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments