// 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() { 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; }
// Use this for initialization void Start() { layer = gameObject.layer; Setup = GetComponent <CarSetup>(); material = Setup.intenceRed; minePrefab = new GameObject("mine"); minePrefab.SetActive(false); mineDecal = new GameObject("mineDecal"); mineDecal.SetActive(false); mineDecal = Resources.Load <GameObject>("explotionDecal"); GameObject mineObject = Resources.Load <GameObject>("mine"); CarSetup.initMesh(minePrefab, mineObject.transform.Find("mine_mesh").GetComponent <MeshFilter>().sharedMesh, material); MeshCollider sensor = minePrefab.AddComponent <MeshCollider>(); sensor.sharedMesh = mineObject.transform.Find("mine_sensor").GetComponent <MeshFilter>().sharedMesh; sensor.convex = true; sensor.isTrigger = true; MeshCollider collider = minePrefab.AddComponent <MeshCollider>(); collider.sharedMesh = mineObject.transform.Find("mine_collider").GetComponent <MeshFilter>().sharedMesh; collider.convex = true; Rigidbody rb = minePrefab.AddComponent <Rigidbody>(); rb.mass = 5; rb.collisionDetectionMode = CollisionDetectionMode.Continuous; minePrefab.layer = layer; ExplosiveController explosive = minePrefab.AddComponent <ExplosiveController>(); explosive.useSensor = true; explosive.damage = explotionDamage; explosive.layer = layer; explosive.explotionForce = explotionForce; explosive.explotionRadius = explotionRadius; explosive.decal = mineDecal; }