using System.Collections; using System.Collections.Generic; using UnityEngine; /// /// 在木马boss关控制地面平铺的类 /// public class HorseGround : MonoBehaviour { void OnTriggerExit2D(Collider2D other){ //如果木马离开了本块地面 if(other.transform.TryGetComponent(out TrojanHorse horse) && !other.isTrigger){ //将本块地面移动到自己右边宽度两倍的位置 transform.position += new Vector3( GetComponent().size.x * 2 * transform.localScale.x,0,0 ); } } }