I’m making a puzzle game that spawns rows as the camera moves down. I have every other part of the code running fine, I’m just having difficulty wrapping my head around this problem.
Summary:
As the camera moves, I have a variable that is checking the position at 5, 4, 3, 2, 1, 0, -1 and so on. When the variable has changed, I’d like to spawn a row of puzzle pieces at that location once, so it builds layers underneath over time.
Code:
I’m currently checking the position of the camera as it moves in the y direction as such:
mainPosition = Mathf.RoundToInt(this.transform.root.position.y);
Questions:
I want to check when the int has updated and then spawn the objects. I just have no idea how to do these things:
- Check when the integer has changed
- Spawn a row once and only once when the integer has changed
I’m currently working in UnityScript. Thanks!