# \[BP Compilation Manager\] WorldContextObject is null in BP function library

**URL:** <https://forums.unrealengine.com/t/bp-compilation-manager-worldcontextobject-is-null-in-bp-function-library/401396>\
**Category:** Blueprint\
**Tags:** UE4-17, unreal-engine, Blueprint, question\
**Created:** [August 9, 2017, 1:23pm UTC](https://forums.unrealengine.com/t/bp-compilation-manager-worldcontextobject-is-null-in-bp-function-library/401396 "2017-08-09T13:23:08Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![MothDoctor](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mothdoctor/32/1194551_2.png) [@MothDoctor](https://forums.unrealengine.com/u/MothDoctor)\
**Post date:** [August 9, 2017, 1:23pm UTC](https://forums.unrealengine.com/t/bp-compilation-manager-worldcontextobject-is-null-in-bp-function-library/401396/1 "2017-08-09T13:23:08Z")

</div>

It’s annoying issue we’ve encountered just after updating to 4.17.  
We use BP function library to call methods like GetGameInstance(), GetPlayerController(). They require WorldContextObject which should automatically retrieved by method call placed in custom library’s function. Sadly functions like GetGameInstance() are provided with WorldContextObject = null.  
It does happen in 4.17 with BP Compilation Manager turned on.  
We didn’t notice any problems outside of function library.

Repro

1. Create a blueprint function library.
2. Add function which simply returns game instance by calling GetGameInstance(), GetPlayerController() or similar. Probably using every function with WorldContextObject will reproduce a bug.
3. Call this function in any actor or level BP.
4. Restart editor. It seems crucial - at some point I though I fixed issue by renaming function library file (there were no errors). But errors came back after reopening project.
5. Play game - make sure you call method from point 2.
6. Stop game. You should get message “There were errors in game” and list of errors in Messages window.

There are two workarounds for this issue.  
A) Turn off Blueprint Compilation Manager in Project Settings.  
B) Pass WorldContextObject from object calling this library’s function. It’s nasty and makes function library not that convenient…

---

<div class="post-metadata">

**Author:** ![Syedhs](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Syedhs](https://forums.unrealengine.com/u/Syedhs)\
**Post date:** [August 9, 2017, 4:09pm UTC](https://forums.unrealengine.com/t/bp-compilation-manager-worldcontextobject-is-null-in-bp-function-library/401396/2 "2017-08-09T16:09:46Z")

</div>

Wow… how can they miss that?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_e729f54e](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_e729f54e](https://forums.unrealengine.com/u/anonymous_user_e729f54e)\
**Post date:** [August 10, 2017, 2:08pm UTC](https://forums.unrealengine.com/t/bp-compilation-manager-worldcontextobject-is-null-in-bp-function-library/401396/3 "2017-08-10T14:08:46Z")

</div>

Hello kjustynski,

I was unable to reproduce this issue on our end with the information provided. I have provided a screen shot of the function in the function library that I used. This setup appears to work without error on my end. Could give this a try and let me know if it works for you?

Example:

 ![204065-functionlibhelp.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/5/e/65ec257efe8ff2db4b1c22a2eba50caca85a0c1f.png)

---

<div class="post-metadata">

**Author:** ![Vuthric](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Vuthric](https://forums.unrealengine.com/u/Vuthric)\
**Post date:** [August 11, 2017, 4:10am UTC](https://forums.unrealengine.com/t/bp-compilation-manager-worldcontextobject-is-null-in-bp-function-library/401396/4 "2017-08-11T04:10:44Z")

</div>

3 days after releasing there’re already a lot of reports on this particular issue. This should be a new and critical bug of 4.17. Print string works fine. However GetAllActorsOfClass inside a function library doesn’t work, not all of the time. It’s fairly unpredictable. Sometimes it works without changing anything. All were fine in 4.16 and I didn’t touch anything.

I’m listing a few similar reports below. They’re all 4.17 and posted within days. With all due respect please invest more resource in resolving this. A tracker link or “unable to reproduce this” doesn’t help. This bug is hell because I’ve done a lot of work in 4.17 before it going rogue. Thank you.

> **[UE4 4.17 World Context in blueprint function library does not work.](https://forums.unrealengine.com/questions/677056/ue4-417-world-context-in-blueprint-function-librar.html)**
>
> Hi, I noticed that in latest 4.17 preview 3 there is a problem with blueprint function libraries and World Context. For example calling "GetGameInstance" inside a blueprint function library now requires a "World Context Object" as input and which...

> **["Error: Script Msg: A null object was passed as a world context object to...](https://forums.unrealengine.com/questions/666822/error-script-msg-a-null-object-was-passed-as-a-wor.html)**
>
> STR: Create new blueprint project. Create AIController blueprint. In AIController blueprint add AIPerception component. Compile AIController blueprint. Result: LogScriptCore: Error: Script Msg: A null object was passed as a world context...

> **[A strange error about GetWorldFromContextObject()](https://forums.unrealengine.com/questions/676246/a-strange-error-about-getworldfromcontextobject.html)**
>
> Check AIController if you had one. I experience same problem with AIPerception component when I compile AIController blueprint and packing a project:...

---

<div class="post-metadata">

**Author:** ![MothDoctor](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mothdoctor/32/1194551_2.png) [@MothDoctor](https://forums.unrealengine.com/u/MothDoctor)\
**Post date:** [August 11, 2017, 4:23pm UTC](https://forums.unrealengine.com/t/bp-compilation-manager-worldcontextobject-is-null-in-bp-function-library/401396/5 "2017-08-11T16:23:59Z")

</div>

I have to admit it was difficult to find a stable repro with fresh functions.  
So… I created a stripped down project with just few scripts necessary to lure out this bug.

It’s should be easy to catch it now. Just open a project and hit Play button 🙂  
[https://drive.google.com/open?id=0B8f7otnD-QKBUEZkR2lWVFVkMHc](https://drive.google.com/open?id=0B8f7otnD-QKBUEZkR2lWVFVkMHc)

To be perfectly clear on this: recompiling or renaming script calling library’s function can “temporarily” fix the issue. It’s coming back after restarting the project.

---

<div class="post-metadata">

**Author:** ![Vuthric](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Vuthric](https://forums.unrealengine.com/u/Vuthric)\
**Post date:** [August 13, 2017, 4:22pm UTC](https://forums.unrealengine.com/t/bp-compilation-manager-worldcontextobject-is-null-in-bp-function-library/401396/6 "2017-08-13T16:22:50Z")

</div>

For those who may need an emergent solution. You can make a C++ AActor and put it in the level as a world context ‘anchor’, which could later be referenced by blueprint function library. Declare:

```
static UObject* WorldContextAnchor;

```

Put the actor in your level. Add this in the constructor:

```
WorldContextAnchor = this;

```

Then make a UBlueprintFunctionLibrary class which reads this static variable and pass it to BP function library as an effective world context (anything in a world can be used as world context). A bit dirty but at least my project is not completely dead now.

---

<div class="post-metadata">

**Author:** ![antoinegloum](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@antoinegloum](https://forums.unrealengine.com/u/antoinegloum)\
**Post date:** [August 14, 2017, 2:35pm UTC](https://forums.unrealengine.com/t/bp-compilation-manager-worldcontextobject-is-null-in-bp-function-library/401396/7 "2017-08-14T14:35:27Z")

</div>

That’s a lot of efforts. Personally, I prefer to stay with the previous release until this bug is fixed.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2d3ed244](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2d3ed244](https://forums.unrealengine.com/u/anonymous_user_2d3ed244)\
**Post date:** [August 14, 2017, 5:51pm UTC](https://forums.unrealengine.com/t/bp-compilation-manager-worldcontextobject-is-null-in-bp-function-library/401396/8 "2017-08-14T17:51:13Z")

</div>

The compilation manager can be disabled via the project settings menu. I’m taking a look at this issue now, but don’t let it block you from using other 4.17 features!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_e729f54e](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_e729f54e](https://forums.unrealengine.com/u/anonymous_user_e729f54e)\
**Post date:** [August 15, 2017, 4:04pm UTC](https://forums.unrealengine.com/t/bp-compilation-manager-worldcontextobject-is-null-in-bp-function-library/401396/9 "2017-08-15T16:04:57Z")

</div>

Hello kjustynski,

**EDIT:**

Was able to reproduce issue the issue using project provided.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2d3ed244](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2d3ed244](https://forums.unrealengine.com/u/anonymous_user_2d3ed244)\
**Post date:** [August 15, 2017, 7:08pm UTC](https://forums.unrealengine.com/t/bp-compilation-manager-worldcontextobject-is-null-in-bp-function-library/401396/10 "2017-08-15T19:08:54Z")

</div>

Sorry for the confusion - this has been logged as UE-48464 (thanks kjustynski for the project!). [Here](https://github.com/EpicGames/UnrealEngine/commit/ca19a3d62278cdcf6f1a5bcde1b965983cb0f3dc) is the fix. I will update this answer when I know what binary release this is a part of - but it should be 4.17.2.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_e12a1674](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_e12a1674](https://forums.unrealengine.com/u/anonymous_user_e12a1674)\
**Post date:** [September 13, 2017, 7:30am UTC](https://forums.unrealengine.com/t/bp-compilation-manager-worldcontextobject-is-null-in-bp-function-library/401396/11 "2017-09-13T07:30:48Z")

</div>

Link fix - 404.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2d3ed244](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2d3ed244](https://forums.unrealengine.com/u/anonymous_user_2d3ed244)\
**Post date:** [September 13, 2017, 6:22pm UTC](https://forums.unrealengine.com/t/bp-compilation-manager-worldcontextobject-is-null-in-bp-function-library/401396/12 "2017-09-13T18:22:27Z")

</div>

If the link appears as a 404 make sure you’re logged in to a github account that is associated with your Epic Games account.

---

<div class="post-metadata">

**Author:** ![Taurian](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Taurian](https://forums.unrealengine.com/u/Taurian)\
**Post date:** [October 10, 2017, 8:00am UTC](https://forums.unrealengine.com/t/bp-compilation-manager-worldcontextobject-is-null-in-bp-function-library/401396/13 "2017-10-10T08:00:13Z")

</div>

Is there a way to disable the compilation manager from outside the project?

I am unable to launch my project since migrating to 4.17.2. I’m thinking this is the culprit.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_e12a1674](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_e12a1674](https://forums.unrealengine.com/u/anonymous_user_e12a1674)\
**Post date:** [October 10, 2017, 8:38am UTC](https://forums.unrealengine.com/t/bp-compilation-manager-worldcontextobject-is-null-in-bp-function-library/401396/14 "2017-10-10T08:38:01Z")

</div>

Yes  
Edit **DefaultEditor.ini**

> [/Script/UnrealEd.BlueprintEditorProjectSettings]
> 
> bUseCompilationManager=False

---

<div class="post-metadata">

**Author:** ![Ebrahim.MR](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ebrahim.mr/32/1220185_2.png) [@Ebrahim.MR](https://forums.unrealengine.com/u/Ebrahim.MR)\
**Post date:** [June 17, 2023, 10:09am UTC](https://forums.unrealengine.com/t/bp-compilation-manager-worldcontextobject-is-null-in-bp-function-library/401396/15 "2023-06-17T10:09:43Z")

</div>

This is a CRAPPY issue. What I have done was, reference all my World objects from getting a function.  
That made it.

```auto
UWorld* USomeClass::GetMyWorld() {
	if ( ensure( ValidActor) && ensure( ValidActor->GetWorld() ) )
		return ValidActor->GetWorld();

	return nullptr;
}

```
