public static FruitBehavior MakeFruit(Vector3 spawnPosition, GameObject fruitPrefab) { if (!LocationUtil.IsOnMap(spawnPosition)) { return(null); } spawnPosition = new Vector3(spawnPosition.x, LocationUtil.groundHeight, spawnPosition.z); Vector3 randomSpawnRotation = Vector3.up * Random.Range(0, 360); var fruit = Instantiate(fruitPrefab, spawnPosition, Quaternion.Euler(randomSpawnRotation)); fruit.name = "Fruit"; return(fruit.GetComponent <FruitBehavior>()); }
// Start is called before the first frame update internal void Start() { closestTree = FindClosestTree(); isOnMap = LocationUtil.IsOnMap(transform.position); }