using UnityEngine;
using System.Collections;
public class Bomb : MonoBehaviour {
// Update is called once per frame
void Update () {
void OnTriggerEnter2D (Collider2D other)
{
Destroy(other.gameObject);
}
}
}
This is my code. What’s causing the error listed in the title?
You put the whole OnTriggerEnter2D method inside Update. It’s supposed to look like this:
using System.Collections;
public class Bomb : MonoBehaviour
{
void Update ()
{
}
void OnTriggerEnter2D (Collider2D other)
{
Destroy(other.gameObject);
}
}
You don’t have to put the void OnTriggerEnter2D inside the update function.
See documentation for example Unity - Scripting API: MonoBehaviour.OnTriggerEnter2D(Collider2D)