# Can I create a static function in C++ which I can access from any Blueprint?

**URL:** <https://forums.unrealengine.com/t/can-i-create-a-static-function-in-c-which-i-can-access-from-any-blueprint/284479>\
**Category:** Blueprint\
**Tags:** unreal-engine, static, function, Blueprint, question\
**Created:** [May 29, 2014, 2:15am UTC](https://forums.unrealengine.com/t/can-i-create-a-static-function-in-c-which-i-can-access-from-any-blueprint/284479 "2014-05-29T02:15:54Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_0074ae5e1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_0074ae5e1](https://forums.unrealengine.com/u/anonymous_user_0074ae5e1)\
**Post date:** [May 29, 2014, 2:15am UTC](https://forums.unrealengine.com/t/can-i-create-a-static-function-in-c-which-i-can-access-from-any-blueprint/284479/1 "2014-05-29T02:15:54Z")

</div>

I’d like to create a function that runs a relatively complex math operation. I have the code already written in C++, but I’d like to be able to access this function from any blueprint, so that any of my actors (or even my level) can use it.

It’s in a custom MathsUtility class that I’m using to hold it as a static function, is there any way I can set this static function up to be access from any blueprint?

---

<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:** [May 29, 2014, 2:49am UTC](https://forums.unrealengine.com/t/can-i-create-a-static-function-in-c-which-i-can-access-from-any-blueprint/284479/2 "2014-05-29T02:49:13Z")

</div>

Yes, same way as you do it with any other functions, UHT will detect that this is static function and will generate node that won’t require “Target” Input

```
UFUNCTION(BlueprintCallable, Category = "Something")
static void DoSomething(UClass* Something);

```

Ofcorse your class you put this in need to be UObject related and have UCLASS() in order for this to work, look on UGameplayStatics on engine source code for example

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_0074ae5e1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_0074ae5e1](https://forums.unrealengine.com/u/anonymous_user_0074ae5e1)\
**Post date:** [May 29, 2014, 2:50am UTC](https://forums.unrealengine.com/t/can-i-create-a-static-function-in-c-which-i-can-access-from-any-blueprint/284479/3 "2014-05-29T02:50:19Z")

</div>

Hm. I had tried this with BlueprintPure and BlueprintCallable, but did not see my static function in the level blueprint available for calling. I will attempt again.

---

<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:** [May 29, 2014, 2:51am UTC](https://forums.unrealengine.com/t/can-i-create-a-static-function-in-c-which-i-can-access-from-any-blueprint/284479/4 "2014-05-29T02:51:26Z")

</div>

i updated anwser 🙂

---

<div class="post-metadata">

**Author:** ![dlwlgns\_1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@dlwlgns\_1](https://forums.unrealengine.com/u/dlwlgns_1)\
**Post date:** [May 29, 2014, 3:05am UTC](https://forums.unrealengine.com/t/can-i-create-a-static-function-in-c-which-i-can-access-from-any-blueprint/284479/5 "2014-05-29T03:05:10Z")

</div>

Also if you uncheck the “Context Sensitive” box in the blueprint thing when you right click to find a function, it’ll make EVERYTHING show up, including your custom stuff. That’s how I figured out how to see my C++ functions in blueprint.

---

<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:** [May 29, 2014, 3:08am UTC](https://forums.unrealengine.com/t/can-i-create-a-static-function-in-c-which-i-can-access-from-any-blueprint/284479/6 "2014-05-29T03:08:24Z")

</div>

Well it works for me, you had that error when you first tried it?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_0074ae5e1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_0074ae5e1](https://forums.unrealengine.com/u/anonymous_user_0074ae5e1)\
**Post date:** [May 29, 2014, 3:08am UTC](https://forums.unrealengine.com/t/can-i-create-a-static-function-in-c-which-i-can-access-from-any-blueprint/284479/7 "2014-05-29T03:08:53Z")

</div>

Yeah I got it working. I had tried using BlueprintImplementableEvent in there and didn’t take it out so compiling was failing. It made me think it wasn’t possible.

Thanks

---

<div class="post-metadata">

**Author:** ![Arty-McLabin](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/arty-mclabin/32/1012076_2.png) [@Arty-McLabin](https://forums.unrealengine.com/u/Arty-McLabin)\
**Post date:** [July 1, 2017, 2:58pm UTC](https://forums.unrealengine.com/t/can-i-create-a-static-function-in-c-which-i-can-access-from-any-blueprint/284479/8 "2017-07-01T14:58:26Z")

</div>

do you guys have a clue on how to do the same with BlueprintNativeEvent?

```
UFUNCTION(BlueprintNativeEvent, Category = "local")

static T getSomething();

static T getSomething_Implementation();

```

the above give a compilation error 😕

---

<div class="post-metadata">

**Author:** ![Godofdrakes](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Godofdrakes](https://forums.unrealengine.com/u/Godofdrakes)\
**Post date:** [August 22, 2017, 5:13pm UTC](https://forums.unrealengine.com/t/can-i-create-a-static-function-in-c-which-i-can-access-from-any-blueprint/284479/9 "2017-08-22T17:13:57Z")

</div>

If I recall correctly UE4 doesn’t support exposing template types to blueprint. There are a few exceptions for collections like TArray, but the type needs to be known or it won’t work.

---

<div class="post-metadata">

**Author:** ![Arty-McLabin](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/arty-mclabin/32/1012076_2.png) [@Arty-McLabin](https://forums.unrealengine.com/u/Arty-McLabin)\
**Post date:** [February 28, 2018, 1:08pm UTC](https://forums.unrealengine.com/t/can-i-create-a-static-function-in-c-which-i-can-access-from-any-blueprint/284479/10 "2018-02-28T13:08:05Z")

</div>

T means some predefined type, not a templated. sorry if it has confused you

---

<div class="post-metadata">

**Author:** ![Sphynxinator](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sphynxinator](https://forums.unrealengine.com/u/Sphynxinator)\
**Post date:** [August 18, 2018, 11:17pm UTC](https://forums.unrealengine.com/t/can-i-create-a-static-function-in-c-which-i-can-access-from-any-blueprint/284479/11 "2018-08-18T23:17:16Z")

</div>

I tried this and Unreal Engine 4 crashed with no trace.
