I have an orb in my game and it rotates 25 degrees per second from a script but I want to make so it can attack and I want it to go faster and faster after every second so it “charges” itself how would you approach that?
Save the rotational speed to a variable, then add a certain amount to that variable every second. Apply rotation to object.
public float originalRotationSpeed = 25f;
public float rotationIncrement = 1f;
public bool incrementRotation = false;
public float currentRotationSpeed;
public void Start()
{
ResetRotation();
}
public void ResetRotation()
{
currentRotationSpeed = originalRotationSpeed;
}
public void Update()
{
float delta = Time.deltaTime;
transform.Rotate(0, currentRotationSpeed * delta, 0);
if(incrementRotation)
{
currentRotationSpeed += rotationIncrement * delta;
}
}