Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class GameController : MonoBehaviour {
- public GameObject Platform;
- public GameObject player;
- public GameObject Text;
- public TimerController TimerScript;
- private Vector3 playerStartPosition;
- private Quaternion playerStartRotation;
- TimerController timerController;
- // Use this for initialization
- void Start ()
- {
- //get that TimerController
- timerController = GameObject.FindObjectOfType<TimerController>(); //use this if there's only one - otherwise find it by tag or gameobject name
- //set the level's duration
- timerController.SetTimer(60f);
- //start the timer ... if this is where you want it to start
- timerController.StartTimer();
- playerStartPosition = player.transform.position;
- playerStartRotation = player.transform.rotation;
- Debug.Log("start pos: " + playerStartPosition.ToString());
- }
- // Update is called once per frame
- void Update ()
- {
- if (player.transform.position.y < -2f)
- ResetPlayer();
- }
- void ResetPlayer()
- {
- Rigidbody playerRigid = gameObject.GetComponent<Rigidbody>();
- Debug.Log("start pos at reset: " + playerStartPosition.ToString());
- Rigidbody.velocity = Vector3.zero;
- Rigidbody.angularVelocity = Vector3.zero;
- player.transform.position = playerStartPosition;
- player.transform.rotation = playerStartRotation;
- Platform.transform.rotation = Quaternion.identity;
- Platform.GetComponent<Rigidbody>().angularVelocity = Vector3.zero;
- TimerScript.AddToTimer(-15f);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement