using System.Collections; using System.Collections.Generic; using UnityEngine; public class Resurrection : MonoBehaviour { public List re = new List();//使用list存储复活点位置 private GameObject ga; // Start is called before the first frame update void Start() { ga =(GameObject)Resources.Load("Character/Vang");//从resousce资源中加载npc Init(); } private void Init() { for (int i = 0; i < 3; i++) { GameObject instance = (GameObject)Instantiate(ga);//实例化npc int a = Random.Range(0, 5);//用随机数保证出生位置的随机性 Vector3 va = re[a].transform.position; //创建局部变量用来保存出生点的位置信息 instance.transform.position = va; } } // Update is called once per frame void Update() { } }