// Use this for initialization void Start() { layer = gameObject.layer; Setup = GetComponent <CarSetup>(); material = Setup.intenceRed; guns = CarSetup.FindGameObjectInChildWithName(transform, "gun"); bulletCD = 1 / rateOfFire; bulletPrefab = new GameObject("bullet"); bulletPrefab.SetActive(false); bulletDecal = new GameObject("bulletDecal"); bulletDecal.SetActive(false); bulletDecal = Resources.Load <GameObject>("bulletHit"); CarSetup.initMesh(bulletPrefab, Resources.Load <Mesh>("bullet"), material); ProyectileController bullet = bulletPrefab.AddComponent <ProyectileController>(); bullet.mode = ProyectileMode.bullet; bullet.speed = bulletSpeed; bullet.damage = bulletDamage; bullet.layer = layer; bulletTimer = new Cooldown(); bulletTimer.init(0, bulletCD); }
// Use this for initialization void Start() { health = GetComponent <HealthModule>(); layer = LayerMask.NameToLayer("shield"); Setup = GetComponent <CarSetup>(); shieldPrefab = Instantiate(Resources.Load <GameObject>("shieldSphere"), transform); shieldPrefab.name = "shield"; GameObject collider = CarSetup.FindGameObjectInChildWithName(shieldPrefab.transform, "collider")[0]; collider.SetActive(false); MeshCollider coll = shieldPrefab.AddComponent <MeshCollider>(); coll.sharedMesh = collider.GetComponent <MeshFilter>().sharedMesh; coll.convex = true; coll.sharedMaterial = Resources.Load <PhysicMaterial>("PhysicsMaterials/noFriction"); shieldPrefab.layer = layer; shieldPrefab.transform.localScale = Vector3.zero; shieldPrefab.SetActive(false); castingTimer = new Cooldown(); castingTimer.init(0, castTime); //shieldPrefab.transform.position = transform.position; //shieldPrefab.transform.parent = transform; }
// Use this for initialization void Start() { Setup = GetComponent <CarSetup>(); material = Setup.intenceRed; pointerMaterial = Setup.transparentRedTexture; layer = gameObject.layer; camera = Setup.camera; targetImage = Setup.canvas.transform.Find("targeting").gameObject; targetingRect = targetImage.GetComponent <RectTransform>(); CanvasRect = Setup.canvas.GetComponent <RectTransform>(); targetImage.SetActive(false); cannons = CarSetup.FindGameObjectInChildWithName(transform, "cannon"); missilePrefab = new GameObject("missile"); missilePrefab.SetActive(false); missileDecal = new GameObject("missileDecal"); missileDecal.SetActive(false); missileDecal = Resources.Load <GameObject>("explotionDecal"); pointerPrefab = new GameObject("pointer"); pointerPrefab.SetActive(false); CarSetup.initMesh(pointerPrefab, Resources.Load <Mesh>("pointer"), pointerMaterial); CarSetup.initMesh(missilePrefab, Resources.Load <Mesh>("missile"), material); MeshCollider collider = missilePrefab.AddComponent <MeshCollider>(); collider.sharedMesh = Resources.Load <Mesh>("missile"); collider.convex = true; missilePrefab.AddComponent <Rigidbody>().mass = 5; ProyectileController missileController = missilePrefab.AddComponent <ProyectileController>(); missileController.mode = ProyectileMode.missile; missileController.propultion = propultion; missileController.damage = missileDamage; missileController.layer = layer; missileController.explotionForce = explotionForce; missileController.explotionRadius = explotionRadius; missileController.decal = missileDecal; }
void Start() { helices = CarSetup.FindGameObjectInChildWithName(transform, "helice"); if (armsA != null) { armsA = CarSetup.FindGameObjectInChildWithName(transform, "armA"); } if (armsB != null) { armsB = CarSetup.FindGameObjectInChildWithName(transform, "armB"); } rotsArmsA = new Vector3[armsA.Length]; rotsArmsB = new Vector3[armsB.Length]; for (int a = 0; a < armsA.Length; a++) { rotsArmsA[a] = armsA[a].transform.rotation.eulerAngles; } for (int a = 0; a < armsB.Length; a++) { rotsArmsB[a] = armsB[a].transform.rotation.eulerAngles; } if (targRotsArmsA == null) { for (int a = 0; a < rotsArmsA.Length; a++) { targRotsArmsA[a] = rotsArmsA[a]; } } if (targRotsArmsB == null) { for (int a = 0; a < rotsArmsB.Length; a++) { targRotsArmsB[a] = rotsArmsB[a]; } } lastPositionY = transform.position.y; GetComponent <Rigidbody>().AddForce(Vector3.up * throwForce, ForceMode.Impulse); }