I am creating a dodge the blocks game where blocks are spawned in front of you and you move to dodge them. when the player has moved past a block, I want to delete the block so there wont be too much lag on mobile devices. If I don’t delete them, the game will get increasingly slower the further you go. This is the script that I am getting this error (line 16)
**
using UnityEngine;
public class Delete : MonoBehaviour {
public GameObject player;
public GameObject me;
private void Awake()
{
player = GameObject.FindGameObjectWithTag("Player");
}
void Update () {
if (player.transform.position.z > transform.position.z)
{
Invoke("DeleteBlock", 3);
}
}
private void DeleteBlock()
{
Destroy(me);
}
}
**