I’ve got an object that I want to rotate. I’ve got a GUI button that I’ve created which handles this just fine. Trouble is, I want the object to continue rotating even after I’ve released the button. Is there a way I can accomplish this with a GUI button? Here’ my simple code so far:
function OnGUI () {
if (GUI.RepeatButton (Rect (25, 25, 130, 30), "Deploy Aentenna")) {
transform.Rotate(Vector3.left * Time.deltaTime * 2);
}
To keep it spinning you could either give the object a rigidbody, turn of it’s gravity, and set rigidbody.angularVelocity = Vector3( direction you want to rotation );
This way the physics engine will keep it spinning. But this could give some unexpected results. It’s probably saver to start a coroutine.