I’ve worked through the tutorial and read all the topics in the comments section. I have a reasonably good grasp of what’s happening here, but I wondered whether we look again at delegates later in the course, particularly regarding something like a custom event system outside of the collision, input, and other “built-in” Unreal events?
I don’t think so. Do you have any particular ideas in mind?
I suppose I’m asking this in relation to a C# for Unity course that I did last year via Coursera. The latter parts of the course involved creating custom event systems. Somewhat confusingly, these still used some of the inbuilt UnityEvent functionality, but basically consisted of an EventManager class that, for each “Event”, kept track of things that could “invoke” those Events and functions that could “listen” for those events and get called when the events fired.
I’m not sure I fully grasped the concept of when an event system like this becomes desirable, but the basic idea seemed to be that it avoided everything in the scene from having to reference everything else. This might be a really bad (and existential) example, but suppose there’s several different NPC classes that can each initiate various forms of interaction, as well as respond to interactions initiated by other NPCs. One thing an NPC can do is scream, and then the other NPC classes respond to that scream in different ways (run away, scream back, etc). Instead of every NPC checking every frame to see if someone has screamed, and instead of the screamer having to hold a reference to all other NPCs to tell them directly that it has screamed, the screamer simply invokes the Scream event, and the event system notifies the other NPCs that a scream event has occurred, which triggers any functions on those NPCs that are listening for an event of that type.
This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.