How could I go about accurately changing movement at a specific time or moment?

Right now I know Time.deltaTime in the Update function is pretty on point when it comes to measuring real time. I have a project where I am using transform.Translate(velocity * Time.deltaTime) in the Update function to move the player. The issue I am having is that I am trying to change my velocity (float variable) to a different amount at a specific time regardless of frame rate or frame rate changes. As in, after starting the scene: change velocity from 14.25f to 13.5f at 5/60 of a second, and then change velocity to 12.75f at 7/60 of a second, and then change velocity to 12f at 11/60 of a second, etc.

.

I made the quick script below to try and better show how I am doing movement at the moment.

.

If it matters, I plan to run my project at 60 frames per second, and I temporary changed the project’s Fixed Timestep to 0.01666667f to help me check the players transform position at a rate close to 60fps by pausing the scene and using the skip button in the editor to move the game one frame at a time.

.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TempMove : MonoBehaviour
{

    public Vector3 velocity;

    void Start()
    {
        velocity.y = 14.25f;
    }

    void Update()
    {
        transform.Translate(velocity * Time.deltaTime);
    }
}

I think you’ll need to accumulate the Time.deltaTime values to get your trigger times.

has a nice example.

Here’s the code I have now, but it is not frame independent because of the if statements within the Update. Currently thinking about how I could make the velocity changes accumulate until the next frame.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TempMove : MonoBehaviour
{
    public float timer = 0.0f;

    public Vector3 velocity;

    void Start()
    {
        velocity.y = 14.25f;
    }

    // Update is called once per frame
    void Update()
    {
        timer += Time.deltaTime;

        //  5/60 <= timer < 7/60 
        if (timer >= 5/60f && timer < 7/60f) 
        {
            velocity.y = 13.5f;
        }

        // 7/60 <= timer < 11/60
        if (timer >= 7/60f && timer < 11/60f) // 11/60
        {
            velocity.y = 12.75f;
        }

        // 11/60 <= timer < 16/60
        if (timer >= 11/60f && timer < 16/60f) 
        {
            velocity.y = 12f;
        }

        // Update the players position using velocity   
        transform.Translate(velocity * Time.deltaTime);

    }
}