// Start is called before the first frame update void Start() { playerGO = GameObject.FindGameObjectWithTag("Player"); bodyPart = GetComponent <TankCoreFunctions>().bodyPart; tankCore = GetComponent <TankCoreFunctions>(); maskPlayerTerrain = LayerMask.GetMask("Terrain", "Player"); }
// Start is called before the first frame update void Start() { playerGO = GameObject.FindGameObjectWithTag("Player"); ownNavMeshAgent = GetComponent <NavMeshAgent>(); tankCore = GetComponent <TankCoreFunctions>(); maskPlayerTerrain = LayerMask.GetMask("Terrain", "Player"); Invoke("CheckRange", 1); }
public void CreateTank(Vector3 spawnPosition, TankyBody basePart, TankyMobility mobilityPart, TankyParts[] attachParts) { //basePart = thisCollection.collectedBody[UnityEngine.Random.Range(0, thisCollection.collectedBody.Length)]; //mobilityPart = thisCollection.collectedMobility[UnityEngine.Random.Range(0, thisCollection.collectedMobility.Length)]; newTank = new GameObject("SpawnedTank"); newTank.transform.position = spawnPosition; ownNavMeshAgent = newTank.AddComponent <NavMeshAgent>(); ownNavMeshAgent.speed = 0; newTank.AddComponent <AIAiming>(); newTank.AddComponent <AIMoving>(); newTankCoreFunctions = newTank.AddComponent <TankCoreFunctions>(); GeneratePart(basePart, newTank.transform); newTankCoreFunctions.bodyPart = newPart; newBasePart.transform.localPosition -= mobilityPart.ownConnectorDistanceOffset; //Offset Body GeneratePart(mobilityPart, newTank.transform); newTankCoreFunctions.mobilityPart = newPart; for (int i = 0; i < attachParts.Length; i++) { if (attachParts[i] != null) { GeneratePart(attachParts[i], newBasePart.transform, basePart.connectorDistanceOffset[i], basePart.connectorAngleOffset[i]); } } /* * for (int i = 0; i < basePart.connectorAngleOffset.Length; i++) * { * weaponPart = thisCollection.collectedWeapon[UnityEngine.Random.Range(0, thisCollection.collectedWeapon.Length)]; * miscPart = thisCollection.collectedMisc[UnityEngine.Random.Range(0, thisCollection.collectedMisc.Length)]; * switch (UnityEngine.Random.Range(0, 3)) * { * case 0: * break; * case 1: * GeneratePart(weaponPart, newBasePart.transform, basePart.connectorDistanceOffset[i], basePart.connectorAngleOffset[i]); * break; * case 2: * GeneratePart(miscPart, newBasePart.transform, basePart.connectorDistanceOffset[i], basePart.connectorAngleOffset[i]); * break; * } * * } */ }