using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class WindCreator : MonoBehaviour {



	[SerializeField] int segments;
	[SerializeField]public float tilt;
	[SerializeField] GameObject windpeice;
	GameObject firstBlood;
	[ContextMenu("CreateWind")]
	public void CreateWind()
	{
		DestroyImmediate (firstBlood);
		GameObject newWind = Instantiate (windpeice, GetComponent<Transform> ()) as GameObject;
		newWind.GetComponent<Transform> ().localPosition = Vector3.zero;
		newWind.GetComponent<Transform> ().localRotation = Quaternion.Euler (Vector3.zero);
		firstBlood = newWind;
		for (int q = 0; q < segments; q++) {
			newWind = Instantiate (windpeice, newWind.GetComponent<Transform>()) as GameObject;
			newWind.GetComponent<Transform> ().localPosition = Vector3.forward * 10	;
			newWind.GetComponent<Transform> ().localRotation = Quaternion.LookRotation (Vector3.forward + Vector3.right * tilt);
		}
	}
}
