#Please post code properly formatted as
1 messages · Page 1 of 1 (latest)
The only piece that was missing is that TestMethod is called from a button click on a UI.
[RplRpc(RplChannel.Reliable, RplRcver.Server)]
void RpcTestMethod()
{
Print("RpcTestMethod called server-side");
}
void TestMethod()
{
Print("TestMethod called client-side");
Rpc(RpcTestMethod);
}
vehicleDataRetrieve.m_OnClicked.Insert(TestMethod);
Where is this code residing? What's the class?
It's in two different classes. TestMethod and RpcTestMethod are part of a class that extends ScriptComponent, and the function that calls TestMethod is in a UI script that extends ChimeraMenuBase
Can you please post the full minimal reproducible example instead of just snippets
There are actually to potential issues already:
- You can only do
RplRcver.Serverwhen the entity is owned by your client. vehicleDataRetrieve.m_OnClicked.Insert(TestMethod);should be inside some init and not outside a method.
I understand wanting to see the context, but that's going to take a while as these are small parts of much larger classes. I assume the issue lies with the actual Rpc call itself as opposed to how anything else is structured, because I can confirm the logic gets executed up until the point of the Rpc call
m_OnClicked is inside another method, I just omitted that as the method it's inside has about 100 other lines of code and figured it wouldn't be worth showing everything else
The first point you made there is likely what's happening though, let me run with that and I'll let you know. Appreciate the help
You can change ownership with RplComponent.Give on the server or you use the local player controller for the Rpc, which is a common approach for sending requests to the server.
That makse sense. I'm working on moving the test Rpc method over to a component I have on the player controller so we'll see what happens
Sure enough that was the problem. I need to go watch the multiplayer workshop videos finally instead of trying to half-ass this code lol
Appreciate it again my friend, you were a huge help
There are two whole bootcamps dedicated to replication 😉