Я пытаюсь добавить элемент в мою игру, где есть пара платформ, и вы можете перейти на платформу № 2 только после того, как вы перешли на платформу № 1, а затем на платформу № 3, когда вы 'прыгал на платформе # 2 и так далее.Я попробовал пару вещей, но не знаю, как лучше всего это сделать.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class OrderedPlatforms : MonoBehaviour
{
[SerializeField]
public List<GameObject> platforms = null;
// Start is called before the first frame update
void Start()
{
//platforms = new List<GameObject>();
for (int i = 1; i < platforms.Count; i++)
{
platforms[i].GetComponent<BoxCollider2D>().isTrigger = true;
}
}
// Update is called once per frame
void Update()
{
}
private void OnCollisionEnter2D(Collision2D collision)
{
for (int i = 0; i < platforms.Count; i++)
{
if(collision.transform.tag == "Player")
{
platforms[i + 1].GetComponent<BoxCollider2D>().isTrigger = false;
}
}
}
}
Я думаю, что ближе всего я приехал, но язастрял здесь.Кто-нибудь, кто может помочь мне здесь?