Hey, I want to destroy the oldest entry of a array of gameobjects. how to ?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class killer : MonoBehaviour {
public Rigidbody2D collider2;
public player script;
public SpriteRenderer spriteRenderer;
public Sprite sprite;
public Collider2D collider1;
// Use this for initialization
void Update () {
}
void Awake()
{
DontDestroyOnLoad(this.gameObject);// to keep the player ragdol when die
}
private void OnTriggerEnter2D(Collider2D collision) // when hit the ground
{
if (collision.tag == "ground")
{
script.enabled = false; // changes of sprite ect...
spriteRenderer.sprite = sprite;
collider2.constraints = RigidbodyConstraints2D.None;
collider1.enabled = false;
Application.LoadLevelAsync(Application.loadedLevelName); // reload the level
}
}
}