i’m currently passing it in to a function via meta(WorldContext) and it ‘works’ but the log complains about no worldcontext.
its ok if i hook it manually in that function but if i then call another function and pass it through it complains again. even using an actor as worldcontext within the function causes it to complain.
i assume its because GetWorld() returns nullptr on the CDO
If you shared the code I could provide a better answer, but in general the solution is that you don’t. If you’re using the CDO for anything and you want to do something that requires a WorldContext, you need to have a way to provide that separately.
This means that if you call a function on the CDO, the function needs its own WorldContext parameter. If the CDO is being used in some other function which wants to call functions needing a WorldContext, then it either needs to come up with one or have its own WorldContext param.
issue was it was working but logging a warning in editor, of course when i went back to take the screenshot the warning was gone so could have been a debug mode thing?
worldcontext was valid and i tested with actors too
i thought the issue may be that it has worldcontext was valid but GetWorld was returning null so it was confusing the editor
question remains the same, is this the best way to do it?
From a design perspective, the CDO itself should not serve as an entity linked to UWorld. I believe the issue you should address is not enabling the CDO to obtain world parameters, but rather avoiding the use of CDO altogether and instead manually creating instances with an appropriate Outer.