赞
踩
public Transform player; public LayerMask mapLayer; [Tooltip("新地图")] public GameObject newMap; [Tooltip("新地图出现在该父组件下")] public Transform parent; [Tooltip("玩家距离边缘多远开始生成新地图")] public float distance; void Start() { } // Update is called once per frame void Update() { //该脚本挂载在新地图出现的点 if (Vector2.Distance(player.position, transform.position) < distance ) { if (!Physics2D.OverlapCircle(transform.position, 0.1f, mapLayer))//如果地图出现点没有地图 { var creat=Instantiate(newMap);//创造地图 creat.gameObject.transform.position = this.transform.position;//将生成的新地图位置变为出现点位置 creat.transform.SetParent(parent); Destroy(this.gameObject); } } }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。