# UPROPERTY required for RPC

**URL:** <https://forums.unrealengine.com/t/uproperty-required-for-rpc/453274>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [August 2, 2019, 11:03pm UTC](https://forums.unrealengine.com/t/uproperty-required-for-rpc/453274 "2019-08-02T23:03:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![xoorath](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@xoorath](https://forums.unrealengine.com/u/xoorath)\
**Post date:** [August 2, 2019, 11:03pm UTC](https://forums.unrealengine.com/t/uproperty-required-for-rpc/453274/1 "2019-08-02T23:03:35Z")

</div>

Hey,

I’m trying to get RPC working on a UObject, and I’m aware I require the following:

```
    bool IsSupportedForNetworking() const override;
    virtual bool CallRemoteFunction(UFunction* Function, void* Parms, FOutParmRec* OutParms, FFrame* Stack) override;
    virtual int32 GetFunctionCallspace(UFunction* Function, void* Parameters, FFrame* Stack) override;

```

Which is fine and well, however I also appear to require a UPROPERTY

```
    UPROPERTY()
    bool bUnused;

```

If I don’t add this useless property the FFieldCache for my class wont be found, and the CallRemoteFunction will fail to call the remote function.

_(screenshot: NetworkDriver.cpp)_

 ![283993-unknown.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/8/8/f88122624336d1693afd0cedc4c81e7797329b1b.png)

Is there a workaround to this? Is there a way to force the creation of a field cache (or subvert the need) for my type without adding a useless property to it?

Thanks.

Also not that I think it’s relevant, but I imagine somebody will want to see it, here’s my implementation of those 3 functions:

```
bool UInteractionBase::IsSupportedForNetworking() const
{
	return true;
}

bool UInteractionBase::CallRemoteFunction(UFunction* Function, void* Parms, FOutParmRec* OutParms, FFrame* Stack)
{
	auto* owner = Cast<AActor>(GetOuter());
	if (ensure(owner != nullptr))
	{
		UNetDriver* netDriver = owner->GetNetDriver();
		if (ensure(netDriver != nullptr))
		{
			netDriver->ProcessRemoteFunction(owner, Function, Parms, OutParms, Stack, this);
			return true;
		}
	}
	return false;
}

int32 UInteractionBase::GetFunctionCallspace(UFunction* Function, void* Parameters, FFrame* Stack)
{	
	auto* owner = Cast<AActor>(GetOuter());
	check(owner != nullptr);
	return (owner ? owner->GetFunctionCallspace(Function, Parameters, Stack) : FunctionCallspace::Local);
}
```

---

<div class="post-metadata">

**Author:** ![xoorath](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@xoorath](https://forums.unrealengine.com/u/xoorath)\
**Post date:** [August 2, 2019, 11:56pm UTC](https://forums.unrealengine.com/t/uproperty-required-for-rpc/453274/2 "2019-08-02T23:56:17Z")

</div>

Not a very satisfying answer, but this appears to be a bug or limitation in Unreal…

In Class.cpp, see SetUpRuntimeReplicationData. This function relies on PropertyLink to not be null despite PropertyLink not being used by this method. If the body of this function is skipped, NetFields will never be populated which is required for there to be a net cache for that class.

Although I don’t suggest it, this can be hacked around pretty easily. This code below will force the NetField’s to be populated:

```
auto oldPropLink = StaticClass()->PropertyLink;
StaticClass()->PropertyLink = StaticClass()->PropertyLink ? StaticClass()->PropertyLink : (UProperty*)1;
StaticClass()->SetUpRuntimeReplicationData();
StaticClass()->PropertyLink = oldPropLink;

```

It’s a hacky proof of concept that appears to work. I have no idea if there are consequences I’m unaware of. I’m going to just use a dummy UPROPERTY though, although I’d suggest the unreal dev’s look into the issue and double check if my assumptions about that null check being not-needed are correct. 🙂

---

<div class="post-metadata">

**Author:** ![BeijingDiana](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/beijingdiana/32/616832_2.png) [@BeijingDiana](https://forums.unrealengine.com/u/BeijingDiana)\
**Post date:** [February 19, 2023, 2:26am UTC](https://forums.unrealengine.com/t/uproperty-required-for-rpc/453274/3 "2023-02-19T02:26:02Z")

</div>

OMG Thanks,I spend 3 weeks to fix UObject RPC issue

---

<div class="post-metadata">

**Author:** ![DaSt45](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/dast45/32/622231_2.png) [@DaSt45](https://forums.unrealengine.com/u/DaSt45)\
**Post date:** [February 19, 2023, 3:53am UTC](https://forums.unrealengine.com/t/uproperty-required-for-rpc/453274/4 "2023-02-19T03:53:06Z")

</div>

A parameter-less UPROPERTY is not useless, it’s a macro that adds reflection to that variable, which is sometime needed.
