- Home /
rpc not arriving and no error
I haveing this weird issue where the code below its first rpc does not arrive at the server and the 2nd rpc sent is calling an non existing function and should give an error. But it does not throw an error either.
What could be wrong?
public function Start() :void
{
// Set the wheel to match the server position
if(Network.isClient && isEnabled)
{
networkView.RPC("GetCurWheelPos", RPCMode.Server, Network.player);
networkView.RPC("GetCur", RPCMode.Server, Network.player);
Debug.Log("ASK WheelPos client");
}
// Server / Singleplay
else
{
if(isEnabled)
{
EnableTrigger();
}
}
}
@RPC
public function GetCurWheelPos(askingPlayer :NetworkPlayer) :void
{
Debug.Log("GET WheelPos server");
networkView.RPC("SetCurWheelPos", askingPlayer, rWheel.rotation);
}
The client side log prints on the client, the server side log is does not print the server. And the not existing function rpc call is not printing an error as it should.
If I use the rpc in a delay function called from Start(), it works. (Still no error on the non existing function tough.)
private function SendRpc() :IEnumerator
{
yield WaitForSeconds(1.00);
networkView.RPC("GetCurWheelPos", RPC$$anonymous$$ode.Server, Network.player);
networkView.RPC("GetCur", RPC$$anonymous$$ode.Server, Network.player);
}
Answer by Bluestrike · Jun 04, 2014 at 10:59 AM
Not really an awnser to why its not working. But the code below seems to work, delaying a second before I send the rpc to the server seems to do the trick. Still no error for the non existent function called in a rpc tough.
public function Start() :void
{
// Set the wheel to match the server position
if(Network.isClient && isEnabled)
{
SendRpc();
Debug.Log("ASK WheelPos client");
}
}
private function SendRpc() :IEnumerator
{
yield WaitForSeconds(1.00);
networkView.RPC("GetCurWheelPos", RPCMode.Server, Network.player);
networkView.RPC("GetCur", RPCMode.Server, Network.player);
}
EDIT: The network connection may not be made during Awake() and Start() calls, explaining why a yield works. I believe we can use OnConnectedToServer() instead.
Answer by tanuj0092 · Jun 03, 2014 at 11:14 PM
In the networkView component of that game object on which this script is attached, the transform must be reffered. Refer this script component at that place. This is the reason why rpc are not working there.
You are talking about the observer property of the networkview? Referencing the script there did not help. And I never had to do that for my rpc's before. Just having the networkview is suposed to make rpc's work.
Your answer