using UnityEngine;
using System.Collections;

public class PlayerControl : MonoBehaviour {

	public float speed = 25f;
	public GameObject cardboardHead;
	Rigidbody rigidbody;


	void Start () {
		rigidbody = GetComponent<Rigidbody>();
	}

	void FixedUpdate () {
		//player input control function
		InputMovement();
	}

	void InputMovement()
	{
		Vector3 acceleration = Vector3.zero;
		float vertAxis = 0;

		//MOVEMENT
//		float horizAxis = Input.GetAxisRaw("Horizontal");
//		acceleration.x = horizAxis;


//		acceleration.x = 0;
//		vertAxis = Input.GetAxisRaw("Vertical");
//		acceleration.z = vertAxis;
//		acceleration.z = 0;



		if (cardboardHead.transform.localRotation.x > 0.1) {
			if (cardboardHead.transform.localRotation.w < 0.9 ) {
				vertAxis = 0 - cardboardHead.transform.localRotation.x;
			} else {
				vertAxis = cardboardHead.transform.localRotation.x;
			}


			acceleration.z = vertAxis;

			//transform.position += acceleration * speed * Time.deltaTime;
			transform.Translate (acceleration * speed * Time.deltaTime);
		}
	}
}
