Hi. I am following along with Unity’s “Flappy Bird Tutorial”, but I do not understand a line of the code in the repeating background script.
// Use this for initialization
void Start ()
{
groundCollider = GetComponent<BoxCollider2D> ();
groundHorizontalLength = groundCollider.size.x;
}
// Update is called once per frame
void Update ()
{
if (transform.position.x < -groundHorizontalLength)
{
RepositionBackground ();
}
}
// Repositions background
private void RepositionBackground()
{
Vector2 groundOffset = new Vector2 (groundHorizontalLength * 2f, 0);
transform.position = (Vector2)transform.position + groundOffset;
}
Mainly, I don’t understand the conditional. Could someone explain it in simple terms? Thank you in advance.