As I’m using a later version of Unreal that features the Include What You Use (IWYU) architecture, for this lecture I have to add a #include to the header file to allow GetWorld() to successfully be called. My issue is that there are 3 versions of GetWorld(), all of which make the code work, but which one should we be using, and what are the differences?
Hey there,
I found that using
#include "Runtime/Engine/Classes/Engine/World.h"
did it for me! Let me know if it doesn’t work, but it should be fine. If you try to include AActor::GetWorld, VS17 complains about not knowing about the UWorld class.
2 Likes
Hey Lucas,
I agree - it makes a lot of sense to include World.h as this is the header that includes the class UWorld, which is the return type of GetWorld().
Hi,
I initially included “Engine/World.h” but my AI could not find the player tank. When I replaced it with “Runtime/Engine/Classes/Engine/World.h” it found the player tank!. Not sure what was happening though !