it really depends on what you want, but you can do this with a coroutine and a loop.
for example:
void Start()
{
StartCoroutine(myRandLoop)
}
public IEnumerator myRandLoop()
{
while(true)
{
float randomSpeed = Random.Range(minSpeed, maxSpeed);
float newY = Mathf.Sin(Time.time * randomSpeed) * height + pos.y;
transform.position = new Vector3(transform.position.x, newY, transform.position.z);
yield return new WaitForSeconds(delayAmount)
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…