Hello Devs!
I want my object to increase rotation speed smoothly from 0 speed to 5 on the z axis, so if someone knows the solution i would be very grateful if you could share it with me!
Here is my code:
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.EventSystems;
public class rotateleft : MonoBehaviour, IEventSystemHandler {
public float speed = 2f;
bool buttonHeld = false;
public void pressed (BaseEventData eventData)
{
buttonHeld = true;
GameObject.Find("LeftImage").GetComponent<Animation>().Play("LEFT");
}
public void notpressed(BaseEventData eventData)
{
buttonHeld = false;
GameObject.Find("LeftImage").GetComponent<Animation>().Play("LEFT1");
}
public void FixedUpdate()
{
if (buttonHeld)
{
transform.Rotate(Time.smoothDeltaTime, 0, speed * Time.deltaTime);
}
}
}