【发布时间】:2019-03-18 16:49:00
【问题描述】:
尝试创建simple endless moving platform,z 上的比例为 70 的 3 个立方体(玩家不会向前移动,只会向左/向右移动)。 RepositionPlatform 脚本附加到每个负责移动的平台/立方体上,并检查每个平台的z position 是否为<= -100.0f, then position is changed to (0,0,200.0f).
问题是有时平台(多维数据集)之间有一点差距,或者有一点我不想要的重叠。
平台应该一个接一个地放置,没有任何间隙或重叠!!!
任何人都可以通过查看脚本来帮助找到问题或提出其他更好的方法吗?
下面的脚本附在3个平台游戏对象上!!!
public class RepositionPlatform : MonoBehaviour
{
private GameObject platformGO;
[SerializeField]
private float speed;
// Start is called before the first frame update
void Start()
{
platformGO = this.gameObject;
Debug.Log("In RepositionPlatform Start method - "+ platformGO.name);
}
// Update is called once per frame
void Update()
{
Debug.Log("In RepositionPlatform Update Method- " + platformGO.name);
platformGO.transform.Translate(Vector3.back * Time.deltaTime * speed);
Transform platformTransform = platformGO.transform;
if(platformTransform.position.z <= -100.0f)
{
platformTransform.position = new Vector3(0,0,200.0f);
}
}
}
【问题讨论】: