Advertisement
Ineedcash12

Untitled

Mar 25th, 2014
366
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.13 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class PlayerController : MonoBehaviour
  5. {
  6.  
  7.  
  8.     public float speed = 1;
  9.     private int count; // Count of astroids picked up
  10.     private int numSpawned; // Number of Astroids spawned
  11.     private Vector3 position; // Astroid spawning range
  12.     public Transform Pickup; // Astroids
  13.  
  14.  
  15.     void start ()
  16.     {
  17.         numSpawned = 1;
  18.     }
  19.  
  20.  
  21.     void FixedUpdate()
  22.     {
  23.         float moveHorizontal = Input.GetAxis("Horizontal");
  24.         float moveVertical = Input.GetAxis("Vertical");
  25.         float moveX = Input.acceleration.x;
  26.         float moveY = Input.acceleration.y;
  27.  
  28.         Vector3 movement = new Vector3(moveX, 0.0f, moveY);
  29.  
  30.         rigidbody.AddForce(movement * speed * Time.deltaTime);
  31.     }
  32.  
  33.     void OnTriggerEnter(Collider other)
  34.     {
  35.         if (other.gameObject.tag == "Pickup") {
  36.             other.gameObject.SetActive (false);
  37.             //int count  ++ 1;
  38.             numSpawned = 0;
  39.  
  40.  
  41.         }
  42.  
  43.  
  44.            
  45.     }
  46.     void update ()
  47.     {
  48.         while (numSpawned < 1) {
  49.             Instantiate(Pickup, position, Quaternion.identity) as Transform;
  50.             position = new Vector3 (Random.Range (-15.0F, 15.0F), .5F, Random.Range (-15.0F, 15.0F));  
  51.         }  
  52.              
  53.         }
  54.                
  55.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement