IEnumerator Timer() { yield return(new WaitForSeconds(Random.Range(3f, 4f))); this.gameObject.transform.Find("dynamite_v02").Find("light").GetComponent <Light> ().intensity = 0; blow = false; //do explosion MyExplosionPhysicsForce physics = explosion.GetComponent <MyExplosionPhysicsForce>(); physics.dealDamage = true; physics.explosionForce = 3000; physics.whoFired = whoFired; Instantiate(explosion, this.transform.position, Quaternion.identity); Destroy(this.gameObject); }
// Update is called once per frame void Update() { this.transform.Rotate(0, 1 * Time.deltaTime * rotSpeed, 0); if (activate) { float dist = (Time.time - startTime) * moveSpeed; this.transform.position = Vector3.Lerp(startPos, endPos, dist / len); if (this.gameObject.transform.position == endPos) { activate = false; Loop(); } } if (loop) { this.transform.RotateAround(endPos, new Vector3(1, 0, 0), 200f * Time.deltaTime); StartCoroutine(ShootRocket()); } if (attack) { endPos = target.transform.position; float dist = (Time.time - startTime) * (moveSpeed + 5f); this.transform.position = Vector3.Lerp(startPos, endPos, dist / len); transform.LookAt(endPos); this.transform.Rotate(90, 0, 0); if (this.gameObject.transform.position == endPos) { attack = false; MyExplosionPhysicsForce physics = Explosion.GetComponent <MyExplosionPhysicsForce>(); physics.dealDamage = false; physics.whoFired = whoFired; physics.explosionForce = 1500; Instantiate(Explosion, this.transform.position, Quaternion.identity); Destroy(this.gameObject); PlayerHealth ph = target.GetComponent <PlayerHealth> (); ph.TakeDamage(damage); ph.lastAttacker = whoFired; } } }
public void playerDead(GameObject go) { Vector3 pos = go.transform.position; playersInScene.Remove(go); go.GetComponent <CarInteractionManager> ().ResetWeapons(); go.SetActive(false); GameObject o = Instantiate(Resources.Load("Transmission", typeof(GameObject))) as GameObject; o.transform.position = pos; MyExplosionPhysicsForce expl = explosion.GetComponent <MyExplosionPhysicsForce>(); expl.dealDamage = false; expl.explosionForce = 1500; Instantiate(explosion, go.transform.position, Quaternion.identity); StartCoroutine(RespawnTimer(go)); }