Hello there,
I was following the “CryptRider” tutorial of the “Unreal 5.0 C++ Developer: Learn C++ and Make Video Games” course after the “GetWorld()” video.
I see that the GetWorld() method gets called in Tick(), and then the UWorld* ptr is used to print some data. I don’t remember if the result gets stored in a UWorld* local variable, but this doesn’t change much, as GetWorld() is still called every frame, and returns a pointer very frame.
The operation itself is not expensive, as GetWorld() is just returning a pointer to “World”, but it’s getting called every frame.
Shouldn’t it be better to just declare a UWorld* pointer variable inside our class and use the BeginPlay method to assign it to the GetWorld() returned ptr only once?
We should be able to access the UWorld using our pointer, but without recalculating it every time.
Or there is no sense in doing what I am saying?
Aren’t we saving some calculations?