I have this script attached to the Main Camera. I want to instantiate an object whenever the camera is at a specific position in the y axis. But the object doesn't instantiate. Here's the script.
public GameObject obj;
private void Update()
{
if (transform.position.y % 2 == 0) {
Instantiate(obj, new Vector3(transform.position.x, transform.position.y), Quaternion.identity);
}
}
Is it something to do with the modulus function? Thank you!