Created
August 22, 2019 08:09
-
-
Save sasherafat-zz/50b02b51e6a44dcd5328ec6efb828d25 to your computer and use it in GitHub Desktop.
Spanw Function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Spawn() { | |
// x position between left & right border | |
int x = (int)Random.Range(borderLeft.position.x, | |
borderRight.position.x); | |
// y position between top & bottom border | |
int y = (int)Random.Range(borderBottom.position.y, | |
borderTop.position.y); | |
// Instantiate the food at (x, y) | |
Instantiate(foodPrefab, | |
new Vector2(x, y), | |
Quaternion.identity); // default rotation | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment