I have this code and I know what it does (it will move an object up and down)
But I don't know how its elements work. Could someone please explain it to me?
IEnumerator Move (Vector3 Target) // What this IEnumerator do?
{
while (Mathf.Abs ((Target - transform.localPosition).y) > 0.1f) {
Vector3 Direction = Target.y == Top.y ? Vector3.up : Vector3.down;
//Is this an if/else? and if yes why if target.y == top.y its first choice is vector3.up?
transform.localPosition += Direction * 5 * Time.deltaTime;
yield return null;
}
yield return new WaitForSeconds(1f);
Vector3 newTarget = Target.y ==Top.y ? Bottom : Top;
//Same line but result order is different ?.?
StartCoroutine(Move(newTarget));
}