How to find the *caller* of a function?

TL;DR: Neither “find references” nor “find in blueprints” returns the “caller” of some functions; alternatives?

I’m trying to understand the code of a Marketplace template I bought. To follow the code, which is required to understand it, I have to be able to not only find where something is defined, but also where it is used/called. Unfortunately, the unreal editor does not seem to provide that functionality (or, it should but it’s broken?).

As an example, the template has two “on death” functions; one in the character blueprint, and one in the controller blueprint. Using “find references” on both functions returns nothing. Using “find in blueprints” from the top of the content folder only returns the two function definitions.

I know that the functions are actually called on death, because I added a “print string” to them. So, since they are called, there must be something something somewhere calling them. I want to know I I can find that. While “on death” sounds like something that could be part of some standard unreal API, there are plenty other functions that are specific to that template, so the “caller” must be part of the template itself.

Looks like my issue was that I wasn’t aware of the calling convention used in replication. The methods I could not find the caller from were all called “OnRep_…”, and I didn’t realize that it was a “reserved” prefix used by the engine itself to replicate changes to the client. It didn’t help that Google did not turn up anything for this, but the keyword to search for is “RepNotify”.

Click the far right button with the binoculars icon. It will list all nodes of that function including event graphs from other blueprints.

7 Likes

Bumping this old topic because I myself had to know the Caller of a function I used everywhere like for example my PrintDebug function which is quite ubiquitous.

I found out that for functions part of a Function Library (which happens to be the case of the functions I use everywhere like PrintDebug) it’s very easy because there’s a node called “World Context” that will give you just that.

Unfortunately this node doesn’t exist in normal blueprints and functions not part of a library, but usually these functions are not used “everywhere” anyway so it’s easier to find the callers if necessary, for example by adding an input parameter dedicated to this.

1 Like

Hey Ahmad here. It sounds like you’re having a tough time tracing back function calls in an Unreal Engine Marketplace template. Unreal’s “find references” and “find in blueprints” can sometimes miss dynamic or event-driven calls. It’s possible these “on death” functions are hooked up to events, delegates, or are overridden from a parent class. Another thing to check might be any kind of state machines or AI logic trees present in the template. They might be calling these functions based on game state or character status changes. If you’re still stuck, maybe try checking any documentation that came with the template or reaching out to the creator. Tracing code in a new template can be challenging, but hang in there, and keep digging!

1 Like

I hope they kept hanging in there but that was 5 years ago ^^

My bad, I bumped an old topic in order to share the solution that worked for me since the topic came up in my Google search, it might help somebody else down the line.

I came across this thread and wanted to share this solution, since I expect this will pop up for other users once in a while:
Tools > Find in Blueprints

Use the query:

Nodes(Name=MyFunction && Pins(Name=Target && ObjectClass=BP_FunctionOwningBP)) 

This will find all places that the function “MyFunction” of a class “BP_FunctionOwningBP” is called in other blueprints. It makes use of the fact that nodes that call a class’s member function will have a Target pin.

fib_target

There isn’t something equally precise for Blueprint Function Libraries, but you can search specifically for function call nodes which will narrow search results down quite a bit:

Nodes(Name=MyFunction && ClassName=K2Node_CallFunction) 

Edit: Wrote an article about it plus a better workaround for function libraries.

2 Likes