I am making a ball rolling game controlled by tilting an accelerometer.
In my game multiple balls overlap, so they end up showing as only one ball. How can I solve this problem, so balls do not overlap?
I have write this script:
public class Accelerometer : MonoBehaviour {
public float Speed=0.5f;
public float Speedy = 8f;
public float HorizantalMin;
public float HorizantalMax;
public float VerticalMin;
public float VerticalMax;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
float Horizental = Input.acceleration.x*Speed;
float UP = Input.acceleration.y*Speedy;
transform.Translate (Horizental, 0f,UP*Time.smoothDeltaTime);
this.transform.position = new Vector3 (Mathf.Clamp (this.transform.position.x, HorizantalMin, HorizantalMax), this.transform.position.y, this.transform.position.z);
this.transform.position = new Vector3 (this.transform.position.x, this.transform.position.y,Mathf.Clamp (this.transform.position.z, VerticalMin,VerticalMax));
}
}
No comments:
Post a Comment