# How do I identify the "\_\_WorldContext" parameter of a UFunction in C++?

**URL:** <https://forums.unrealengine.com/t/how-do-i-identify-the-__worldcontext-parameter-of-a-ufunction-in-c/488686>\
**Category:** Rendering\
**Tags:** reflection, ufunction, unreal-engine, CPP, question\
**Created:** [September 12, 2021, 10:19am UTC](https://forums.unrealengine.com/t/how-do-i-identify-the-__worldcontext-parameter-of-a-ufunction-in-c/488686 "2021-09-12T10:19:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![fluffy-kalashnikov](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@fluffy-kalashnikov](https://forums.unrealengine.com/u/fluffy-kalashnikov)\
**Post date:** [September 12, 2021, 10:19am UTC](https://forums.unrealengine.com/t/how-do-i-identify-the-__worldcontext-parameter-of-a-ufunction-in-c/488686/1 "2021-09-12T10:19:35Z")

</div>

Hi! I’ve been trying to make a console for a school project using Unreals reflection. It works by referencing blueprint function libraries in a settings panel, and then calling them using UObject::ProcessEvent.

Now, the problem is that every function made in Blueprint in these function libraries autogenerate a UObject\* “\_\_WorldContext” parameter, which I can’t find a clean way to get and fill. The current solution found below compares the FNames, but that is something I really despise as any whacky designer could rename the variable in Blueprint.

```
for (TFieldIterator<FProperty> It(Function); It && (It->PropertyFlags & (CPF_Parm | CPF_ReturnParm)) == CPF_Parm; ++It, NumParamsEvaluated++)
{
	FProperty* PropertyParam = *It;
	checkSlow(PropertyParam);

	// @TODO: REPLACE MAGIC STRING CONSTANT
	const static FName WorldContextParam = FName(TEXT("__WorldContext"));
	if (It->GetFName() == WorldContextParam) //executes if this is the WorldContext parameter
	{
		FObjectPropertyBase* Op = CastField<FObjectPropertyBase>(PropertyParam);
		if (GEngine && Op && this->IsA(Op->PropertyClass))
		{
			// Fills the first found local player as the WorldContext.
			APlayerController* Player = GEngine->GetFirstLocalPlayerController(GetWorld());
			Op->SetObjectPropertyValue(Op->ContainerPtrToValuePtr<uint8>(Parms), Player);

			UE_LOG(LogTemp, Warning, TEXT("[WRLD]: %s %s %s"), *Op->GetCPPType(), *Op->GetName(), Op->GetObjectPropertyValue(Parms) ? TEXT("true") : TEXT("false"));
			continue;
		}
	}
}

```

Is there any good way to get hold of this parameter in builds? Just saving the last FProperty found would make C++ commands annoying as almost every other C++ function in the engine has WorldContextObject as the first parameter, and accessing the WorldContext from the UFUNCTION metadata sadly isn’t an option…
