当我在为一个建塔游戏(比如这个)编写代码时,我需要一种生成塔的方法,所以我使用了 Instantiate 并为转换创建了一个名为“place”的变量,并尝试使用 for 循环变量。但它没有用。
这是我的脚本:
using System.Collections;
using System.Collections.Generic;
using Unity.Mathematics;
using UnityEngine;
public class spawner : MonoBehaviour
{
public float3 startingLocation;
Transform place;
public void SpwanTower(float xx, float yy, float zz, GameObject Brick)
{
for (int i = 0; i < yy; i++)
{
for (int e = 0; e < xx; e++)
{
for (int o = 0; o < zz; o++)
{
Instantiate(Brick,place);
}
}
}
}
}