Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class globalFlock : MonoBehaviour {
- public GameObject fishPrefab;
- public GameObject gol;
- public static int tankSize = 5;
- static int numFish = 20;
- public static GameObject[] allFish = new GameObject[numFish];
- public static Vector3 goalPos = Vector3.zero;
- // Use this for initialization
- void Start ()
- {
- for(int i = 0; i < numFish; i++)
- {
- Vector3 pos = new Vector3(Random.Range(-tankSize,tankSize),
- Random.Range(-tankSize,tankSize),
- Random.Range(-tankSize,tankSize));
- GameObject g = (GameObject) Instantiate(fishPrefab);
- g.transform.SetParent (transform);
- g.transform.localPosition = pos;
- g.transform.rotation = Quaternion.identity;
- allFish [i] = g;
- }
- }
- // Update is called once per frame
- void Update ()
- {
- if(Random.Range(0,10000) < 50)
- {
- goalPos = new Vector3(Random.Range(-tankSize,tankSize),
- Random.Range(-tankSize,tankSize),
- Random.Range(-tankSize,tankSize));
- gol.transform.localPosition = goalPos;
- }
- }
- }
Add Comment
Please, Sign In to add comment