Event continuously triggered

Hi all, I have a concern about performance. In the solution proposed during the lesson I noticed that the events are continuously triggered during the game, even if the door has completed its path to the target angle. Does this continuous execution of the events affect the performance of the game? Isn’t it better to protect the execution of the onClose/onOpen event with a boolean variable “isDoorOpen” like the following, so that the event is executed just one time?

void UOpenDoor::OpenDoor()
{
if (!isDoorOpen)
{
onOpen.Broadcast();
isDoorOpen = true;
}
}

void UOpenDoor::CloseDoor()
{
if (isDoorOpen)
{
onClose.Broadcast();
isDoorOpen = false;
}
}

Privacy & Terms