Hello, so I am trying to make a menu, lets say it has 5 different boxes in it. Each of these boxes is connected to a character, and when this character dies, I want the box to be deleted, this is working fine. However lets say character 3 is killed, I want box 4 and 5 to shift up to fill in the gap, currently I am only able to make it so that all of the boxes move up, does anyone know how to solve this? Here’s what I’m working with:
using UnityEngine;
using System.Collections;
public class Game_Sorting : MonoBehaviour
{
private GameObject[] menu;
private GameObject[] selected;
void OnDestroy()
{
menu = GameObject.FindGameObjectsWithTag("SurvivoursMenu");
foreach (GameObject om in menu)
{
if (gameObject.transform.position.y <= om.transform.position.y)
{
om.transform.position = new Vector3(om.transform.position.x, om.transform.position.y + 45, 0);
}
}
}
}
The first method that I can think of (what you can see me trying to implement in the script) is making all boxes with a lower y value of the box being destroyed shift up, but this either makes them all move up or nothing move up, depending on the “>”, and I don’t seem to be able to add this to GameObject[ ] list. Another method I was thinking was giving each one a spawn number, e.g box one = 1, box two = 2, so on, but I don’t know how to implement this yet. Any advice or links of where to go to would be great, I can’t seem to find anything about this online.