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