Is there a way to see the C++ code in blueprint nodes for learning purposes?

I am trying to learn C++ and I was curious about seeing how Unreal’s blueprints work under the hood, just a curiosity…
I was wondering if there is a way I could open up every blueprint node like “try get pawn owner” or “get vector direction” what it looks like in C++

Most nodes in blueprint are C++ function bindings, they are normal functions C++. UHT automaticly converts names of functions, it places spaces before uppercapped letters, so remove spaces and search C++ API refrence, in API refrence you will have header file and source file path where function been declered and defined, which help you find the function in source code. In some cases function have custom names, then it little harder to search, you need to search node name in source code or API refrence and have some luck. But sometimes Blueprint API refrence hints where to look at, which the case with “get vector direction”

https://docs.unrealengine.com/latest/INT/BlueprintAPI/Math/Vector/GetDirectionVector/index.html

Description hints that this function is declered KismetMathLibrary (note in engine source code blueprints are sometime named Kismet 2 or K2) which contains set of standard math function for blueprint. So you search for KismetMathLibrary in github and we find KismetMathLibrary.h (usally in Public or Classes directory) and there we have this function decleration:

UFUNCTION(BlueprintPure, Category="Math|Vector")
static FVector GetDirectionVector(FVector From, FVector To);

We search for cpp file (usally in Private directory) and we see function code:

/** Find the unit direction vector from one position to another. */
FVector UKismetMathLibrary::GetDirectionVector(FVector From, FVector To)
{
	return (To - From).GetSafeNormal();
}

https://github.com/EpicGames/UnrealEngine/blob/311e18ff369078e192a83f27834b45bdb288168a/Engine/Source/Runtime/Engine/Private/KismetMathLibrary.cpp#L977

Now let’s try “try get pawn owner”, i remove spaces and search C++ API refrence and i find this:

It tells as we can find code in Runtime/Engine/Private/Animation/AnimInstance.cpp, so we go there and find the code:

APawn* UAnimInstance::TryGetPawnOwner() const
{
	USkeletalMeshComponent* OwnerComponent = GetSkelMeshComponent();
	if (AActor* OwnerActor = OwnerComponent->GetOwner())
	{
		return Cast<APawn>(OwnerActor);
	}

	return NULL;
}

https://github.com/EpicGames/UnrealEngine/blob/311e18ff369078e192a83f27834b45bdb288168a/Engine/Source/Runtime/Engine/Private/Animation/AnimInstance.cpp

Note that Target pin in nodes are auto generated, it defines on which object function is called, by that it also tells you in which class function is made. Static functions don’t have “Target” pin as they don’t need object to be called on, but it still somewhere in some class.

There also custom nodes, which is not just function call and has custom behavior coded. Those nodes are classes derived from UK2Node class:

Note that “CallFunction” node that bind C++ function is also there. They are way more complex as they also defines how virtual machine bytecode is formed during compilation. You can find there code here:

https://github.com/EpicGames/UnrealEngine/tree/e607ba4d978c08a26e8e8e629dec0884bb161770/Engine/Source/Editor/BlueprintGraph/Private

Most common symptom that node is not normal function call, is diffrent node icon, not blue or green “f” icon.

Also importent note, events (not delegates) are also functions, they just cosmeticly diffrent and they are made so it easy to override them in blueprints. They have BlueprintImplementableEvent specifier

And they dont have code definition in C++, it’s generated by UHT and calling this function in C++ triggers event, so you need to search where it is called. Because code in event is generated (to call event in blueprint) and you can’t place C++ code in to it event are usally declered as a duplicate function and it’s called in original C++ event function (and node usally is custom named after original function):

void AActor::BeginPlay()
{
	SetLifeSpan( InitialLifeSpan );

	ReceiveBeginPlay(); // <-Blueprint event being called
}

https://github.com/EpicGames/UnrealEngine/blob/e607ba4d978c08a26e8e8e629dec0884bb161770/Engine/Source/Runtime/Engine/Private/Actor.cpp#L2454