# Static function with DefaultToSelf?

**URL:** <https://forums.unrealengine.com/t/static-function-with-defaulttoself/411422>\
**Category:** Blueprint\
**Tags:** unreal-engine, static, function, question, Blueprint, CPP\
**Created:** [December 5, 2017, 8:28am UTC](https://forums.unrealengine.com/t/static-function-with-defaulttoself/411422 "2017-12-05T08:28:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Napoleonite](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Napoleonite](https://forums.unrealengine.com/u/Napoleonite)\
**Post date:** [December 5, 2017, 8:28am UTC](https://forums.unrealengine.com/t/static-function-with-defaulttoself/411422/1 "2017-12-05T08:28:54Z")

</div>

I’m trying to create a visible Target-pin for Blueprints that defaults to “self” for a static function like this one:

![222623-want.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/8/0/580c309dbde1a5ed336961833fb7840a6d7be6be.png)

This is what I have now (but does not work):

```
UFUNCTION(BlueprintCallable, Category = "Custom", meta = (DefaultToSelf = "target"))
static void PrintError(UObject* target, const FString errorMessage = "Cast failed.");

```

I looked at how UE4 does it. Example:

```
UFUNCTION(BlueprintCallable, BlueprintCosmetic, Category="User Interface|Animation")

```

Erm… It does not even have DefaultToSelf. So how does one implement this pin?

---

<div class="post-metadata">

**Author:** ![Napoleonite](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Napoleonite](https://forums.unrealengine.com/u/Napoleonite)\
**Post date:** [December 8, 2017, 12:37pm UTC](https://forums.unrealengine.com/t/static-function-with-defaulttoself/411422/2 "2017-12-08T12:37:22Z")

</div>

I found how to do it for invisible pins but still now how to do it for visible ones:

```
// Prints a custom error 
UFUNCTION(BlueprintCallable, Category = "Custom", meta = (WorldContext = "worldContextObject", ShowWorldContextPin))
static void PrintError(UObject* worldContextObject, const EErrorLocationType ErrorLocType = EErrorLocationType::NameOnly, const FString errorMessage = "Cast failed.");

```

ShowWorldContextPin does not work and neither does it when putting it in the UCLASS() but at least I can default to self. But I can’t seem to be able to expose the pin VISIBLY.

---

<div class="post-metadata">

**Author:** ![Fayntek](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/fayntek/32/946342_2.png) [@Fayntek](https://forums.unrealengine.com/u/Fayntek)\
**Post date:** [July 4, 2024, 1:18am UTC](https://forums.unrealengine.com/t/static-function-with-defaulttoself/411422/3 "2024-07-04T01:18:59Z")

</div>

meta = (DefaultToSelf = “ControlledPawn”)

Seems like im 7 years late, you can specify a default to self pin with meta; instead “ControlledPawn” you can specify your desired variable reference that you want reference to self in declaration of function on UFUNCTION
