объявить после if )
c#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Generator : MonoBehaviour
{
public Terrain terrain;
public GameObject[] loot;
void Start()
{
float w = terrain.terrainData.size.x / 32.0f;
float h = terrain.terrainData.size.y / 32.0f;
GameObject odj = loot[Random.Range(0, loot.Length)];
if(odj != null)
{
i = Random.Range(0, 32);
odj.transform.position = new Vector3(i w, terrain.transform.position.y + 100, i h);
Instantiate(odj);
}
}
}