using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PickUp : MonoBehaviour {
// Use this for initialization
private int score = 0;
void Start () {
transform.position = new Vector3(Random.Range(-9, 9), 1, Random.Range(-9, 9)); //食物随机出生
}
// Update is called once per frame
void Update () {
transform.Rotate(0,-1,1); //食物旋转
}
void OnTriggerEnter(Collider collider)
{
if (collider.name == "Ball")
{
if (score < 14)
{ transform.position = new Vector3(Random.Range(-9, 9), 1, Random.Range(-9, 9)); } //重新生成食物
else
{ Destroy(gameObject); } //删除食物
score++;
}
}
}
using System.Collections.Generic;
using UnityEngine;
public class PickUp : MonoBehaviour {
// Use this for initialization
private int score = 0;
void Start () {
transform.position = new Vector3(Random.Range(-9, 9), 1, Random.Range(-9, 9)); //食物随机出生
}
// Update is called once per frame
void Update () {
transform.Rotate(0,-1,1); //食物旋转
}
void OnTriggerEnter(Collider collider)
{
if (collider.name == "Ball")
{
if (score < 14)
{ transform.position = new Vector3(Random.Range(-9, 9), 1, Random.Range(-9, 9)); } //重新生成食物
else
{ Destroy(gameObject); } //删除食物
score++;
}
}
}