# Blueprint Function Libraries and World Context?

**URL:** <https://forums.unrealengine.com/t/blueprint-function-libraries-and-world-context/495293>\
**Category:** Blueprint\
**Tags:** unreal-engine, UE4-27, Blueprint, question\
**Created:** [February 7, 2022, 1:55pm UTC](https://forums.unrealengine.com/t/blueprint-function-libraries-and-world-context/495293 "2022-02-07T13:55:26Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Error\_Trap](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/error_trap/32/88706_2.png) [@Error\_Trap](https://forums.unrealengine.com/u/Error_Trap)\
**Post date:** [February 7, 2022, 1:55pm UTC](https://forums.unrealengine.com/t/blueprint-function-libraries-and-world-context/495293/1 "2022-02-07T13:55:26Z")

</div>

I am trying to understand the purpose of World Context in relation to Blueprint Function Libraries.

If I create an empty Blueprint Function Library, create a new function called “Foo”, leave it empty, and try and use “Foo” in certain classes, it will require me to pass in a World Context object to “Foo”. Now “Foo” doesn’t interact with the game world, or any objects for that matter (in this example its a no-op) and the same method copied directly into the calling class works without requiring a World Context.

What is the purpose/need to have World Context required in Blueprint Function Libraries; and is there a way around this?

---

<div class="post-metadata">

**Author:** ![dzemzmcdonalda](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/dzemzmcdonalda/32/1214680_2.png) [@dzemzmcdonalda](https://forums.unrealengine.com/u/dzemzmcdonalda)\
**Post date:** [July 17, 2022, 6:19pm UTC](https://forums.unrealengine.com/t/blueprint-function-libraries-and-world-context/495293/2 "2022-07-17T18:19:20Z")

</div>

Answered in this post

> [@Why World Context pin appears on function nodes called inside of Blueprint Function Library?](https://forums.unrealengine.com/t/why-world-context-pin-appears-on-function-nodes-called-inside-of-blueprint-function-library/606834/2):
>
> Thats nothing you should worry about (if gives you an error just connect it with the world context variable). But basicly, every function that comes from a function library (not from an actor), needs to have a reference in the world to be executed. That’s why it appears, when you call a function from a class that comes from the the class actor it will assume that the world context is the actor itself, that’s why it not appears in characters and actors, it still there but it just not visible.

---

<div class="post-metadata">

**Author:** ![eldany.uy](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/eldany.uy/32/821920_2.png) [@eldany.uy](https://forums.unrealengine.com/u/eldany.uy)\
**Post date:** [July 17, 2022, 8:16pm UTC](https://forums.unrealengine.com/t/blueprint-function-libraries-and-world-context/495293/3 "2022-07-17T20:16:11Z")

</div>

When function libraries need a reference of the world sometimes for some tasks…  
for example get all actors with some tag…the function need to know the world where those actors are…or a delta time, etc.

There is a way to tell the library function to use the actor that is calling it as world context object so the world context pin does not appears in the blueprint node and is adding the meta WordlContext.

Example:

```auto
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "My Blueprint Library" , DisplayName = "get delta seconds in a function", meta = (WorldContext = "WorldContext") )
     	static float GetDeltaSecs(const UObject* myWorldContext)
     	{
     		if (myWorldContext)
     		{
     			return myWorldContext->GetWorld()->GetDeltaSeconds();
     		}
     		else { return -1; }
     	}

```

Hope this helps! 🙂

Dany

---

<div class="post-metadata">

**Author:** ![Error\_Trap](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/error_trap/32/88706_2.png) [@Error\_Trap](https://forums.unrealengine.com/u/Error_Trap)\
**Post date:** [July 22, 2022, 3:28am UTC](https://forums.unrealengine.com/t/blueprint-function-libraries-and-world-context/495293/4 "2022-07-22T03:28:16Z")

</div>

Unfortunately that doesn’t really answer the question; it just hand waves and says don’t worry about it; but often I use Blueprint Function Libraries from Blueprints that do not have a world context, and shouldn’t need one.

Imagine I have a simple Blueprint Function Library that has a single function called “Add”. It takes two floats, and returns the value of the two added together. I wouldn’t expect this to need a reference to the world context.

---

<div class="post-metadata">

**Author:** ![GeoffHowland](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@GeoffHowland](https://forums.unrealengine.com/u/GeoffHowland)\
**Post date:** [January 12, 2024, 1:52am UTC](https://forums.unrealengine.com/t/blueprint-function-libraries-and-world-context/495293/5 "2024-01-12T01:52:56Z")

</div>

I passed in my Pawn actor and it accepted it.

---

<div class="post-metadata">

**Author:** ![bibbis](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@bibbis](https://forums.unrealengine.com/u/bibbis)\
**Post date:** [June 21, 2024, 11:08am UTC](https://forums.unrealengine.com/t/blueprint-function-libraries-and-world-context/495293/6 "2024-06-21T11:08:04Z")

</div>

I would love for someone to follow up on this.  
I’ve created several BGLs in our project and today I created a new function where World Context is being automatically added this way.  
It’s the first time I’ve ever seen this behavior.

Here’s and example:  
One function takes an input actor and gets equipment data directly from the actor and returns currently equipped weapon. For some reason the function auto generates a World Context input.  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/b/b/ebb9a42185d24083d00853ed869aebed1b340245.png)

Another function spawns an object, which would potentially require a World context, but the function doesn’t auto generate such an input. However, there still seems to be an auto generated World Context VARAIBLE.  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/5/b/55bd0cbc109d4814148b65f528dda3c3eb2168b5.png)

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/c/e/ace6556bfe1467f6093df275a9e89dc27666cf4d.png)

It’s always these inconsistencies that leave me confused and a bit irritated.
