Multiple 2D Movements Moving at Slightly DIfferent Speeds

I’m sure this is just a basic thing. I have a scene here, the Sun and Moon move to their next waypoint whenever I click “Next Turn”… No problem there so far, however where the problem does arise is that despite that both of them being the same speed, one of them can get to a waypoint faster than the other, I suspect because of the nature of the Update() functions. The idea is that both the sun and moon need to get to their waypoint at the same time so that the player cannot spam next turn and have either the sun or moon jump ahead of the other a waypoint. (Note that before the sun or moon can move they have to be very close to their waypoint’s position but if one travels faster than the other and someone presses next turn there could be both the sun and moon in the sky or out of the sky because one reaches it’s waypoint first which is not desirable obviously.)

Pictures and script below to describe.

public GameObject sun;
public GameObject moon;

[HideInInspector]
public int iSun, iMoon;

public float speed;//This is to control how fast the sun and moon are moving

public List<Transform> wayPointCycle;

public class DayNightCycle : MonoBehaviour
{

private void Start()
    {
        iSun = 0;
        sun.transform.position = wayPointCycle[0].position;

        iMoon = 3;
        moon.transform.position = wayPointCycle[3].position;
    }

void Update()
    {
        Cycle();
    }

void Cycle()
    {

        if(Vector3.Distance(sun.transform.position, wayPointCycle[iSun].position) >= 0.15f)
        {
            sun.transform.position = Vector3.MoveTowards(sun.transform.position, wayPointCycle[iSun].position, Time.deltaTime * speed);
        }
        if (Vector3.Distance(moon.transform.position, wayPointCycle[iMoon].position) >= 0.15f)
        {
            moon.transform.position = Vector3.MoveTowards(moon.transform.position, wayPointCycle[iMoon].position, Time.deltaTime * speed);
        }
    }
}

This is how it’s actually moving. iSun and iMoon are incrementing by 1 every time the “Next Turn” button is pressed (unless it’s the last in the list ofc). Any help appreciated :slight_smile:

If logically they need to always be the same at the same point of progress, use a single variable to control that.

Using the single variable, set the rotation of each based on your waypointing table and whatever your fixed offset between the two is.