Im getting this error for my trigger
BroadcastMessage OpenDoor has no receiver! UnityEngine.GameObject:BroadcastMessage (string,object) OpenDoor:OnTriggerEnter2D (UnityEngine.Collider2D) (at Assets/Scripts/OpenDoor.cs:8)
The two scripts are on different objects, one is a child of the other.
OpenDoor.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class OpenDoor : MonoBehaviour
{
void OnTriggerEnter2D(Collider2D collision){
gameObject.BroadcastMessage("OpenDoor", 5.0);
}
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}
DoorOpened.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DoorOpened : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
void OpenDoor(float door){
Debug.Log("door");
}
}
}
I am new to coding.
Both GameObjects have a collider and rigidbody2D.