スロー、ポーズ
スローモーションにしたい時
if (Input.GetKey(KeyCode.Space)) { Time.timeScale = 0.5f; }else{ // 以下がなければ、一度押せばスローのまま。 Time.timeScale = 1.0f; }
【Unity Action】 ポーズメニュー怖い(Time.timeScale = 0 関連の話): Karasuのアプリ奮闘記
例えば、カメラにつけたり。
using UnityEngine; using System.Collections; public class RotateCamera : MonoBehaviour { void Update() { // transform.RotateAround(回転基準点, 軸を決める, 速度); transform.RotateAround(Vector3.zero, new Vector3(2, 2, 1), 4 * Time.deltaTime); if (Input.GetKey(KeyCode.Space)) { Time.timeScale = 0.5f; }else{ Time.timeScale = 1.0f; } } }
繰り替えを行うときに、bool型の変数を使って、静止かどうかを決める。
public bool paused = false; void Update () { if(Input.GetButtonUp("A")){ if(!paused){ Time.timeScale = 0; paused = true; }else{ paused = false; Time.timeScale = 1; } } }
追記2015/05/05