I created a brick breaker game and it works fine on PC. When I click on screen (or touch Android device screen), a ball appears and start moving forward. But on Android it won’t move at all. Here’s my code:
In PaddleControl script:
public class BaseController : MonoBehaviour {
public float speed = 5.0f;
public GameObject prefabBall = null;
public GameObject startPoint = null;
public bool createBall = true;
// Use this for initialization
void Start () {
}
void Update () {
// When touch screen, create a ball at startPoint
if (Input.touchCount > 0 Input.GetTouch(0).phase == TouchPhase.Ended createBall) {
Instantiate (prefabBall, startPoint.transform.position, prefabBall.transform.rotation);
createBall=false;
}
}
}
In Ball script:
public class Ball : MonoBehaviour {
public Vector3 direction = Vector3.up;
public float speed = 1.0f;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
transform.position += direction * speed * Time.deltaTime;
// transform.Translate (direction * speed * Time.deltaTime);
// try both ways but no one works (both work on PC)
}
}
I try many ways without successful, the ball doesn’t move. I even created a very simple project with a sphere on screen and a script using
void Update () {
transform.Translate (direction * Time.deltaTime);
}
but result was still the same. Can someone tell me if I did something wrong?
Sorry for my bad English.