using UnityEngine;
using System.Collections;

[RequireComponent(typeof(Rigidbody))]
public class TracerController : MonoBehaviour {

    public float baseVelocity = 5F;
    private Rigidbody myRigidbody = null;

    void Start() {
        myRigidbody = GetComponent<Rigidbody>();
        myRigidbody.velocity = transform.forward * baseVelocity;
    }

    void Update() {
        float rotation = 0F;

        if (Input.GetKeyDown(KeyCode.LeftArrow)) {
            rotation = -90F;
        } else if (Input.GetKeyDown(KeyCode.RightArrow)) {
            rotation = 90F;
        }

        if (rotation != 0F) {
            transform.Rotate(0F, rotation, 0F);
            myRigidbody.velocity = transform.forward * baseVelocity;
        }
    }
}
