Hello All,
I have an aerial view Camera facing the ground
and I have a script that works with Arrow Keys (up down left & right) to move it
There is also touch input that works horizontally (x axis) but not vertically (normally y but since I am aerial it is z)
What am I doing wrong?
Here is the javascript
#pragma strict
// Moves object according to finger movement on the screen
var speed : float = 0.05;
var nonSpeed : float = 0;
function Update () {
if (Input.GetKey(KeyCode.RightArrow) ){
Debug.Log("right");
transform.Translate (Vector3(10,0,0) * Time.deltaTime*speed);
}
if ( Input.GetKey(KeyCode.LeftArrow) ){
Debug.Log("left");
transform.Translate (Vector3(-10,0,0) * Time.deltaTime*speed);
}
if ( Input.GetKey(KeyCode.UpArrow) ){
Debug.Log("Up");
transform.Translate (Vector3(0,-10,0) * Time.deltaTime*speed);
}
if ( Input.GetKey(KeyCode.DownArrow) ){
Debug.Log("Down");
transform.Translate (Vector3(0,10,0) * Time.deltaTime*speed);
}
if (Input.touchCount > 0 &&
Input.GetTouch(0).phase == TouchPhase.Moved) {
// Get movement of the finger since last frame
var touchDeltaPosition:Vector3 = Input.GetTouch(0).deltaPosition;
// Move object across XZ plane
transform.Translate (-touchDeltaPosition.x * speed,
0,0);
transform.Translate (-touchDeltaPosition.z * speed,
0,0);
}
}
Thanks
~be