using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Rotations : MonoBehaviour
{
public Text textName;
public float rotationSpeed;
public bool rotateText = false;
public string textToDisplay;
public float displayCurrentSpeed;
public float rotationDuration;
public float startAngle;
public float stopAngle;
public AnimationCurve curve;
private float currentRotationTime;
private void Start()
{
textName.text = textToDisplay;
}
private void Update()
{
Vector3 namePos = Camera.main.WorldToScreenPoint(this.transform.position);
textName.transform.position = namePos;
if(rotateText)
{
/*currentRotationTime += Time.deltaTime;
var progress = curve.Evaluate(currentRotationTime / rotationDuration);
var currentAngle = startAngle + (stopAngle - startAngle) * progress;
textName.transform.rotation = Quaternion.Euler(0f, currentAngle, 0f);
*/
if (currentRotationTime < 3f)
{
currentRotationTime += Time.deltaTime;
textName.transform.Rotate(0, rotationSpeed * currentRotationTime, 0);
}
}
}
}
Using the animationcurve is working fine but I want to make that the speed will increase slowly to maximum speed and that it will keep rotating on that maximum speed.
The problems is how to limit the rotation speed to maximum ? and how to display the current rotation speed to see the rotation speed get increasing ?
Doing :
if (currentRotationTime < 3f)
Is not limiting the maximum rotation speed.