Setting the xMin and xMax

Hi everyone, just have a general question / idea about how the xMin and xMax variables are set in this video. The way I did the challenge, is that I just made the xMin and xMax variables from the PlayerController static, and access them this way in the EnemySpawner (PlayerController.xMin). I did this because I figured instead of making extra calls to Camera. and repeating the same code to set the boundaries we have already written, that this would be a more efficient way of getting those boundaries. While I get that maybe there would be a better place to put this code, rather than the PlayerController, it just made sense to me to make those static values as they aren’t changing and could be used in the EnemeySpawner script as well. Any thoughts/suggestions?

1 Like

I think it’s a very interesting idea. I hope someone with more experience can corroborate the efficiency of your approach, and I think you could create a script (not linked to any object) that contains the static values that will be used in more than one class. :thinking:

Privacy & Terms