# How to access non-static members in a Blueprint Function Library class?

**URL:** <https://forums.unrealengine.com/t/how-to-access-non-static-members-in-a-blueprint-function-library-class/462359>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [March 11, 2020, 5:07pm UTC](https://forums.unrealengine.com/t/how-to-access-non-static-members-in-a-blueprint-function-library-class/462359 "2020-03-11T17:07:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ale1221](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ale1221](https://forums.unrealengine.com/u/Ale1221)\
**Post date:** [March 11, 2020, 5:07pm UTC](https://forums.unrealengine.com/t/how-to-access-non-static-members-in-a-blueprint-function-library-class/462359/1 "2020-03-11T17:07:25Z")

</div>

In my game I am using a class which inherits from UBlueprintFunctionLibrary where I have defined a couple of static functions .I need to call non-static functions while inside the static ones and also use static variables, but I have no idea how to do it since I can’t get an instance of the blueprint function library class. I tried with

```
UMyBlueprintFunctionLibrary Self;
Self.MyFunction();

```

Where MyFunction is a non-static function. However the engine crashes at the first line with the error

> Fatal error: [File:D:/Build/++UE4/Sync/Engine/Source/Runtime/CoreUObject/Private/UObject/UObjectGlobals.cpp] [Line: 3193] FObjectInitializer::Get() can only be used inside of UObject-derived class

Is there any solution that isn’t declaring every function and variable as static?

---

<div class="post-metadata">

**Author:** ![Doctor\_Kannon](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/doctor_kannon/32/1130101_2.png) [@Doctor\_Kannon](https://forums.unrealengine.com/u/Doctor_Kannon)\
**Post date:** [March 11, 2020, 5:49pm UTC](https://forums.unrealengine.com/t/how-to-access-non-static-members-in-a-blueprint-function-library-class/462359/2 "2020-03-11T17:49:50Z")

</div>

I would assume the non-static Fns could call the static Fns, but not vice-versa.

This might help.

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — ue4community.wiki! You will be able to find content from the official...

Haven’t tried **call()** in UE4. Not sure if it’s possible.

> <https://stackoverflow.com/questions/13331447/static-function-call-non-static-function-in-c>

Function Libraries are generally useful, and help organize code/BPs, but they do have some restrictions.

---

<div class="post-metadata">

**Author:** ![Shadowriver](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Shadowriver](https://forums.unrealengine.com/u/Shadowriver)\
**Post date:** [March 14, 2020, 4:47pm UTC](https://forums.unrealengine.com/t/how-to-access-non-static-members-in-a-blueprint-function-library-class/462359/3 "2020-03-14T16:47:49Z")

</div>

UBlueprintFunctionLibrary class is dedicated to bluerpint node function that don’t fit to any other class or original classes are not in reflection system (most notable example is FMath). UBlueprintFunctionLibrary don’t have any code, BlueprintCallable and BlueprintPure static or non-static works the same anywhere. so it’s existence is purly for organization

UBlueprintFunctionLibrary should not be used for non-static function, if you do then you probably doing something wrong. First think if you really need to use UBlueprintFunctionLibrary, remember BlueprintCallable can used anywhere, and non-static function should be in class relevant to it, there no issue of having static functions on other class either if there code is relevant to hosting class, it’s purely your choose and organization matter.

If you have no access class you want to operate in the function to declare function in it, pass it as a argument insted.

If you need access UWorld, there actually special way to do it in static function without need of any extra pins or other hacks, you declare function like this:

```
UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"), Category = "Something")
static void FunctionName(const UObject* WorldContextObject);

```

then in function it self you do:

```
UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);

```

WorldContextObject wont be visible in the node, blueprint system will automatically pass proper object. From UWorld you can access many global objects which also allows you to avoid making pins to pass them.
