Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma strict
- var count : int;
- var countText : GUIText;
- var winText : GUIText;
- var jumpheight : float;
- function Start()
- {
- count = 0;
- countText.text = "Counter: " + count.ToString();
- winText.text = " ";
- }
- function FixedUpdate () {
- var horizontal : float = Input.GetAxis("Horizontal");
- var vertical : float = Input.GetAxis("Vertical");
- var speed : float = 3;
- rigidbody.AddForce(Vector3(horizontal*speed,0,vertical*speed));
- if (Input.GetButton("Jump")) {
- Jump();
- }
- }
- // Destroy everything that enters the trigger
- function OnTriggerEnter (other : Collider) {
- if(other.gameObject.tag== "Pickup")
- other.gameObject.SetActive(false);
- count++;
- countText.text = "Counter: " + count.ToString();
- if(count >= 8)
- {
- winText.text="You Win!";
- yield WaitForSeconds(3);
- Application.LoadLevel("level2");
- }
- }
- function Jump() {
- rigidbody.AddForce(Vector3.up * jumpheight);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement