我想知道如何设置以下代码以在每次创建对象时增加实例化位置,因此它们都彼此相邻排列。目前他们只是为了同一个地点而战,然后开始围成一圈跳舞。
public void AddUnit(string unitName, Vector3 spawnPoint, Vector3 rallyPoint, Quaternion rotation, Building creator)
{
rallyPoint += new Vector3(-10, 0, 0);
Units units = GetComponentInChildren<Units>();
spawnPoint += new Vector3(0, 0, -8);
GameObject newUnit = (GameObject)Instantiate(ResourceManager.GetUnit(unitName), spawnPoint, rotation);
newUnit.transform.parent = units.transform;
Unit unitObject = newUnit.GetComponent<Unit>();
if (unitObject)
{
unitObject.SetBuilding(creator);
if (spawnPoint != rallyPoint)
{
unitObject.StartMove(rallyPoint);
}
}
}
跃然一笑
相关分类