using UnityEngine;
using System.Collections;

public class Box_Move_Z: MonoBehaviour {

	public float movmentSpeed = 1f;
	float minMove = 0.75f;
	float maxMove = 2F;
	float movePos;


	public CharacterController player;



	
	

	void Awake(){
		movePos = Random.Range(0,2);
		
	}
	// Use this for initialization
	void Start () {

		movmentSpeed = Random.Range(minMove,maxMove);

		if(movePos == 0){
			movmentSpeed = movmentSpeed * -1;
			
		}


		
	}

	void OnCollisionEnter (Collision collison){
		movmentSpeed = movmentSpeed * -1;

	}
	
	// Update is called once per frame
	void Update () {
		
		if(Input.GetAxis("Horizontal") != 0 || Input.GetAxis("Vertical") != 0 || !player.isGrounded){
			transform.Translate(0,0, movmentSpeed * Time.deltaTime);
			
	}

	
		
		
		

		
		
		
	}

}