Advertisement
Guest User

Untitled

a guest
Aug 27th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using Chronos;
  4.  
  5. public class TimeControlTest : BaseBehaviour {
  6.  
  7. private float moveSpeed =1.0f;
  8.  
  9. void Update () {
  10. //この書き方だと、キー操作しても期待通りの時間制御ができない。
  11. //transform.Translate(Vector3.up * Time.deltaTime);
  12.  
  13. if(time.timeScale >0){
  14. time.rigidbody.velocity = new Vector3(transform.localScale.x*moveSpeed,time.rigidbody.velocity.y,0);
  15. }
  16.  
  17. Clock clock = Timekeeper.instance.Clock("Root");
  18. if (Input.GetKeyDown(KeyCode.Alpha1)){
  19. clock.localTimeScale = -1; // Rewind:巻き戻し
  20. }else if (Input.GetKey(KeyCode.Alpha2)){
  21. clock.localTimeScale = 0; // Pause:停止
  22. }else if (Input.GetKeyDown(KeyCode.Alpha3)){
  23. clock.localTimeScale = 0.5f; // Slow:ゆっくり移動
  24. }else if (Input.GetKeyDown(KeyCode.Alpha4)){
  25. clock.localTimeScale = 1; // Normal:通常速度で移動
  26. }else if (Input.GetKeyDown(KeyCode.Alpha5)){
  27. clock.localTimeScale = 2; // Accelerate:速く移動
  28. }
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement