Advertisement
Guest User

Untitled

a guest
Sep 5th, 2015
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class GameController : MonoBehaviour {
  5. public GameObject Platform;
  6. public GameObject player;
  7. public GameObject Text;
  8.  
  9. public TimerController TimerScript;
  10. private Vector3 playerStartPosition;
  11. private Quaternion playerStartRotation;
  12. TimerController timerController;
  13. // Use this for initialization
  14. void Start ()
  15. {
  16. //get that TimerController
  17. timerController = GameObject.FindObjectOfType<TimerController>(); //use this if there's only one - otherwise find it by tag or gameobject name
  18.  
  19. //set the level's duration
  20. timerController.SetTimer(60f);
  21.  
  22. //start the timer ... if this is where you want it to start
  23. timerController.StartTimer();
  24.  
  25. playerStartPosition = player.transform.position;
  26. playerStartRotation = player.transform.rotation;
  27. Debug.Log("start pos: " + playerStartPosition.ToString());
  28.  
  29. }
  30.  
  31. // Update is called once per frame
  32. void Update ()
  33. {
  34. if (player.transform.position.y < -2f)
  35. ResetPlayer();
  36. }
  37.  
  38. void ResetPlayer()
  39. {
  40. Rigidbody playerRigid = gameObject.GetComponent<Rigidbody>();
  41. Debug.Log("start pos at reset: " + playerStartPosition.ToString());
  42. Rigidbody.velocity = Vector3.zero;
  43. Rigidbody.angularVelocity = Vector3.zero;
  44. player.transform.position = playerStartPosition;
  45. player.transform.rotation = playerStartRotation;
  46. Platform.transform.rotation = Quaternion.identity;
  47. Platform.GetComponent<Rigidbody>().angularVelocity = Vector3.zero;
  48. TimerScript.AddToTimer(-15f);
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement