我写了一个脚本让敌人出现在玩家后面,每3分钟有5次机会,我已经把五分之一的机会改为一次机会进行测试,但我不确定是否有用.
我知道如何将敌人放在玩家身后,但不会有机会获得1对5.
我已经尝试过1到5之间的随机数.如果随机数等于1,他必须产生敌人,否则不会.
这是代码:
using UnityEngine;
using System.Collections;
public class MainEnemy : MonoBehaviour
{
public GameObject Main;
public GameObject Holder;
public Transform player;
public Transform FPSController;
bool wantPosition;
bool appear;
float timer;
Vector3 temp;
// Use this for initialization
void Start()
{
wantPosition = true;
appear = false;
temp = new Vector3(0, 0, 0);
timer = 20;// 180;
}
// Update is called once per frame
void Update()
{
Appear();
}
Vector3 GetPosition()
{
Debug.Log("Hij doet het getposition");
float px …
Run Code Online (Sandbox Code Playgroud)