Blueprint library function with "default self-value" parameter

Hello, in C++ I wish to make a blueprint function library for easy access to informations stored inside of a component owned by actors of many kinds (e.g. health value stored inside the component inside of an animal, wall or player).
I made a function which works perfectly and, obviously, it takes an “actor reference” as an input, and I’d like that variable to have a “self” value as a default, how can I do?

can you explain a littie more do you mean like the get a reference to self drag off ?

I attached two screenshots of the “forseeable” use of the function: the first is the “usual” use, an actor needs to know another actor’s life, but I’d like to use this function even in the second case, having an actor ask its own health (instead of the conventional “component ref → get health”).
Actually the function works in both the cases, but I’d like the left pin to have a “self” value as a default, similar to a “get actor location” node, so that, in the second application, only a single node is required.

The code is the following for the .h file:

	UFUNCTION(BlueprintCallable, BlueprintPure)
	static int32 Straight_GetHealth(AActor* ActorToGetInformations);

and the .cpp file:

int32 URCL_CombatFunctions::Straight_GetHealth(AActor* ActorToGetInformations)
{
	if (ActorToGetInformations)
	{
		return GetHealthComponent(ActorToGetInformations)->GetHealth();
	}
	
	return -100000000; //health can't have negative values, so this is a good return value for invalid input
}

There is a UFUNCTION meta specifier to do this :

UFUNCTION(BlueprintPure, Meta=(DefaultToSelf="ActorToGetInformations"))
static int32 Straight_GetHealth(AActor* ActorToGetInformations);

Note: BlueprintPure implies BlueprintCallable.

Note2: If that doesn’t work you might need to add HidePin=“ActorToGetInformations” as well.

1 Like

Note 1: thanks!
Note 2: with HidePin it’s impossible to add a different actor from self.

Anyway the solution works because using a simple print string the returned datas are correct, but it still doesn’t show the classic “self box” that the in built in functions have in the left pin, such as “get actor location”; actually that’s not particularly important, so if no other solution is suggested I’ll mark the answer as correct!