using UnityEngine;

public class SteeringWheel : MonoBehaviour {
	public float MaxAngle = 35;
	public float SteeringFactor { get; set; }

    private Tire[] tires;

	void Start () {
        tires = GetComponentsInChildren<Tire>();
	}
	
	void Update () {
		foreach(Tire t in tires)
			if(t.Turning)
				Steer(t);
	}
	
	private void Steer(Tire t)
	{	
		//Debug.Log ("Now steering tire " + t.name + " with SteeringFactor " + SteeringFactor);
		t.transform.localEulerAngles = new Vector3(0, 0, -(SteeringFactor*MaxAngle));
	}
	
}
