So Im trying to instantiate a unit with a z offset of 5 from the factory instantiating it but the new object just goes to (0,0,5) instead of the factorys transform.position + offset.
public class SpawnInfantryUnits : MonoBehaviour
{
public GameObject lesserDeathUnit;
public GameObject lesserWarUnit;
public static GameObject lesserDeath;
public static GameObject lesserWar;
Vector3 spawnSpot;
public Vector3 posOffset;
private void Start()
{
spawnSpot = transform.position;
print(spawnSpot);
spawnSpot += posOffset;
print(spawnSpot);
}
private void OnMouseDown()
{
UIManager.InfantryUnits.SetActive(true);
UIManager.Research.SetActive(false);
UIManager.buildMain.SetActive(false);
UpgradeSupply.upgradeSupply.SetActive(false);
UIManager.Min.SetActive(true);
// UIManager.unitMain.SetActive(false);
}
public void SpawnLesserDeath()
{
if (Stats.population < Stats.maxPopulation)
{
print("pop check pass");
print(spawnSpot);
if (Stats.money >= 125)
{
lesserDeath = (GameObject)Instantiate(lesserDeathUnit, spawnSpot, Quaternion.identity);
//lesserDeath.transform.parent = gameObject.transform;
Stats.units.Add(lesserDeath);
Stats.money -= 125;
print("Death Spawn");
}
else
{
BuildingSelect.SupplySelected = false;
print("Too poor");
}
}
}
public void SpawnLesserWar()
{
if (Stats.population < Stats.maxPopulation)
{
print("pop check pass");
if (Stats.money >= 125)
{
lesserWar = (GameObject)Instantiate(lesserWarUnit, transform.position + posOffset, Quaternion.identity);
//lesserWar.transform.parent = gameObject.transform;
Stats.units.Add(lesserDeath);
Stats.money -= 125;
print("War Spawn");
}
else
{
BuildingSelect.SupplySelected = false;
print("Too poor");
}
}
}
}