Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class Flame : MonoBehaviour
- {
- public bool WithParent;
- public Transform FlameCell;
- public float FlameRate;
- public Vector2 Speed;
- public Vector2 Size;
- float timer;
- public Vector2 lifetime;
- public Vector3 ellipsoid;
- public Gradient colors;
- public bool AnimCell;
- //void
- void Update ()
- {
- timer += Time.deltaTime;
- if (timer > FlameRate)
- {
- Transform tr = Instantiate (FlameCell, transform.position + new Vector3 (Random.Range (ellipsoid.x, -ellipsoid.x), Random.Range (ellipsoid.y, -ellipsoid.y), Random.Range (ellipsoid.z, -ellipsoid.z)), transform.rotation) as Transform;
- if (WithParent)
- {
- tr.parent = transform;
- }
- if (!AnimCell) {
- tr.GetComponent<FlameCell> ().speed = Random.Range (Speed.x, Speed.y);
- tr.GetComponent<FlameCell> ().grad = colors;
- float rndScale = Random.Range (Size.x, Size.y);
- tr.localScale = new Vector3 (rndScale, rndScale, rndScale);
- tr.GetComponent<FlameCell> ().LifeTime = Random.Range (lifetime.x, lifetime.y);
- } else
- {
- tr.GetComponent<FlameCellAnim> ().Lifetime = Random.Range (lifetime.x, lifetime.y);
- }
- timer = 0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement