- Home /
works well On computer but not on phone,reads well on computer but not on phone
Ok i made some code that reads fingure swipes.. if i swipe to the right the object is suppose to go to the right and when i swipe to the left the object suppose to go to the left. I used the unity remote to help me debug and it works well when i use the remote but when i build and run the object doesn't move. it seems that touchphase.ended always equals 0 when its on my phone .` var Ball : GameObject;
function Start () {
}
function Update () {
if( Input.touchCount > 0){
if(Input.GetTouch(0).phase == TouchPhase.Began){
var startPos : Vector2 =Input.GetTouch(0).deltaPosition;
// Spawn Ball//
Instantiate(Ball, new Vector2( startPos.x, -4), Quaternion.identity);
}
if( Input.GetTouch(0).phase == TouchPhase.Ended){
var endPos : Vector2 = Input.GetTouch(0).position;
GameObject.Find("Newtext").GetComponent(TextMesh).text = "relse" + endPos;
}
Debug.Log("Start " + startPos);
Debug.Log("End " + endPos);
if ( startPos.x < endPos.x){
GameObject.Find("Ball").SendMessage("MoveRight");
}
else if( startPos.x > endPos.x){
GameObject.Find("Ball").SendMessage("MoveLeft");
}
` ,
Comment