Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class PlayerController : MonoBehaviour
- {
- public float speed = 1;
- private int count; // Count of astroids picked up
- private int numSpawned; // Number of Astroids spawned
- private Vector3 position; // Astroid spawning range
- public Transform Pickup; // Astroids
- void start ()
- {
- numSpawned = 1;
- }
- void FixedUpdate()
- {
- float moveHorizontal = Input.GetAxis("Horizontal");
- float moveVertical = Input.GetAxis("Vertical");
- float moveX = Input.acceleration.x;
- float moveY = Input.acceleration.y;
- Vector3 movement = new Vector3(moveX, 0.0f, moveY);
- rigidbody.AddForce(movement * speed * Time.deltaTime);
- }
- void OnTriggerEnter(Collider other)
- {
- if (other.gameObject.tag == "Pickup") {
- other.gameObject.SetActive (false);
- //int count ++ 1;
- numSpawned = 0;
- }
- }
- void update ()
- {
- while (numSpawned < 1) {
- Instantiate(Pickup, position, Quaternion.identity) as Transform;
- position = new Vector3 (Random.Range (-15.0F, 15.0F), .5F, Random.Range (-15.0F, 15.0F));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement