I’d like to instantiate a prefab and then check later if it has a firing script that makes it shoot at a designated target. But I’d like to pass it the target at runtime. Because Interfaces can’t inherit from MonoBehaviour, I obviously can’t do this:
public interface ICanFireAtTarget {
public AddTarget(GameObject target);
public FireAtTarget();
}
How can I achieve this behaviour then? How can check if an object has a script that can receive another gameObject as a target?