How to increase and decrease rotating speed

I have speed data like 10 m/s, 6 m/s, 15 m/s, 20 m/s. I want to rotating speed increase by 10 m/s after time speed 6 m/s something like that variable speed. I already wrote rotating speed script code as follow:

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

public class RotateGO : MonoBehaviour
{
float speed = 1.0f;

// Start is called before the first frame update
void Start()
{
    
}

// Update is called once per frame
void Update()
{
    //transform.Rotate(Vector3.up * speed * Time.deltaTime);
    transform.Rotate(speed, 0, 0);
    speed += Time.deltaTime;
    speed -= 0.4f;
           }

}

Please help for write correct script file
Thank you

Hi, there is no such m/s things about rotation but only degrees. If i understand you want to increase your rotation based on the elapsed time.

That should do the trick :

public float Speed;
private float _currentTime;

void Update() {
   _currentTime += Time.deltaTime;
   transform.Rotate(Speed * _currentTime, 0, 0)
}

You can also use rigidBody.AddTorque() if you want to simulate this using physics.


EDIT : to calculate your speed based on your time

For that you need to use a cross product with backing zero.

With MinTime, MaxTime, MinSpeed, MaxSpeed, _currentTime, _currentSpeed

_currentSpeed = MinSpeed + ((MaxTime - MinTime) * (_currentTime - MinTime) / (MaxSpeed - MinSpeed))

Not tested but it’s seems to be okay.

You probably need to add some condition to check if the _currentTime is below MinTime

This is my code. It’s running well. But I want to change “time Random.Range” by the Time Loop.
How to write and fix Time loop code in this script?