Virtual methods understanding

Hi!

I’m in the UE5 C++ course, in the Virtual methods section (174), and Sam explains that Unreal can’t set up a pointer to a particular class because it says that it would require to change the whole engine every time.

I don’t understand that point, can’t I just do something like Pistol* MyPistol instead Gun* MyPistol? I would like a more detailed explanation about this!

Thank you. :smiley:

That’s your own code.

The engine iterates all actors in the world and calls their BeginPlay function. It would be done by something like

// within the UWorld
TArray<AActor*> ActorsInWorld;

/// in UWorld::BeginPlay
for (AActor* Actor : ActorsInWorld)
{
    Actor->BeginPlay();
}

How do you think this would work for Actor types that you create that Epic has no knowledge of their exitense?

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms