using UnityEngine;
using System.Collections;

public class PlayerController2 : MonoBehaviour {

	Rigidbody r_body;
	Animator anim;


	public float move_force;
	public float max_speed;

	// Use this for initialization
	void Start () {
		r_body = GetComponent<Rigidbody>();
	}
	
	// Update is called once per frame
	void Update () {
		float h = Input.GetAxis("Horizontal2");
		float v = Input.GetAxis ("Forward2");
		GameObject gun = GameObject.FindGameObjectWithTag ("Gun");

		r_body.AddForce(new Vector3(move_force * h, 0, move_force * v));

		if(r_body.velocity.x > max_speed)
		{
			r_body.velocity = new Vector3(max_speed, 0, r_body.velocity.y);
		}
		else if(r_body.velocity.x < max_speed * -1)
		{
			r_body.velocity = new Vector3(max_speed * -1, 0, r_body.velocity.y);
		}


	}



}
