I’m also new to C++. I believe you have to get your character’s movement component and declare it as a pointer. Here’s the code I came up with, and it works:
When I need to access the world, I just get the reference from something that has a valid GetWorld().
In my case, I had a UObject-derived class (GameManager) that needed a reference to the world. To get it, I override GameManager’s GetWorld() (which it inherits from UObject) to have it reference TextUI, which is a blueprint class and thus has a valid GetWorld().
That should work, but it’s possible where you are doing those changes is causing them to get stomped by the incoming data for those fields that is set through the editor. Try moving the code to some place like PostLoad, or elsewhere.
If you are referencing a UObject/Actor, you can simply call “GetWorld()” from the UObject which will get you its’ World. Otherwise you can include “Engine/Engine.h” and use “GEngine->GetWorld()” which should get you the world as well (normally there is only 1 world so this is probably fine - the exception being an Editor session in which case there could be multiple worlds).
Calling “GetWorld()” from a UObject you already have a reference to, is by far the safest/easiest way.