Question by
panoramabeats · Dec 18, 2016 at 07:57 PM ·
scripting problemstartstoprestart
Best way to Start/Stop script during runtime.
Specifically a Spin/Rotation script on a GameObject.
It should stop/start on a GetKeyDown for space bar on desktop. It is a mobile app, so I will have to create a UI button for this.
Ideally, it should revert back to the start position, instead of "pausing" and continuing. Here's the script: (it works, I know there's some extra brackets, etc)
using UnityEngine; using System.Collections;
public class Spin : MonoBehaviour {
public float speed = 10f;
// Update is called once per frame
void Update () {
transform.Rotate (Vector3.forward, speed * Time.deltaTime);
// {
//}
}
}
Comment
Your answer
Follow this Question
Related Questions
How can i disable a function in C# 1 Answer
Can't restart a level 2 Answers
Start() and Awake() not called on MonoBehaviour 1 Answer
Countdown Timer 1 Answer
Noob: Fresh install play/stop problem 0 Answers