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
using UnityEngine; | |
using System.Collections; | |
public class SpawnFood : MonoBehaviour { | |
// Food Prefab | |
public GameObject foodPrefab; | |
// Borders | |
public Transform borderTop; | |
public Transform borderBottom; |
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
// Use this for initialization | |
void Start () { | |
// Spawn food every 4 seconds, starting in 3 | |
InvokeRepeating("Spawn", 3, 4); | |
} |
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) |
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
using UnityEngine; | |
using System.Collections; | |
public class SpawnFood : MonoBehaviour { | |
// Food Prefab | |
public GameObject foodPrefab; | |
// Borders | |
public Transform borderTop; | |
public Transform borderBottom; |
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
using UnityEngine; | |
using System.Collections; | |
public class SpawnFood : MonoBehaviour { | |
// Food Prefab | |
public GameObject foodPrefab; | |
// Use this for initialization | |
void Start () { | |
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
using UnityEngine; | |
using System.Collections; | |
public class SpawnFood : MonoBehaviour { | |
// Use this for initialization | |
void Start () { | |
} | |
} |
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
using UnityEngine; | |
using System.Collections; | |
public class SpawnFood : MonoBehaviour { | |
// Use this for initialization | |
void Start () { | |
} | |