using UnityEngine;
using System.Collections;
public class tank : MonoBehaviour {
public int speed = 10;
public int force = 5000;
public Rigidbody sphere;
public Transform barrel;
public int x = 0;
public int y = 10;
public int z = 0;
public float tankForce = 0.3f;
// Use this for initialization
void Start () {
transform.position = new Vector3 (x, y, z);
}
// Update is called once per frame
void Update () {
//basic movement
transform.Translate (Vector3.forward * Input.GetAxis("Horizontal") * speed * Time.deltaTime);
transform.Translate (Vector3.right * Input.GetAxis ("Vertical") * speed * Time.deltaTime );
transform.Translate (Vector3.up * Input.GetAxis("Jump") * speed * Time.deltaTime);
if (Input.GetButtonDown("Fire1")){
transform.Translate(Vector3.left * tankForce);
Rigidbody clone;
clone = Instantiate(sphere, barrel.position, barrel.rotation)as Rigidbody;
force = force + 10;
clone.rigidbody.AddForce(barrel.right * force);
}
}
}