-
Notifications
You must be signed in to change notification settings - Fork 449
Add SendTo.MeAndServer #3443
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Have you tried anything like this? private ulong[] m_ServerAndMe;
public void SendToMeAndServer()
{
// One way to do this
SendToMeAndServerRpc(RpcTarget.Server);
SendToMeAndServerRpc(RpcTarget.Me);
// Another way to handle this
if (m_ServerAndMe == null)
{
m_ServerAndMe = new ulong[] { NetworkManager.ServerClientId, NetworkManager.LocalClientId };
}
SendToMeAndServerRpc(RpcTarget.Group(m_ServerAndMe, RpcTargetUse.Temp));
}
[Rpc(SendTo.SpecifiedInParams)]
private void SendToMeAndServerRpc(RpcParams rpcParams = default)
{
} |
Yes, that works too. However, I still think having |
It really depends upon what you are trying to accomplish by invoking an Rpc locally and also sending the Rpc to the server using that approach. As an example: public class SomeBehaviour : NetworkBehaviour
{
public void InvokeServerAndMe()
{
if (!IsServer)
{
InvokeServerSideRpc();
}
///////////////////////////////
// Add the the script you want to be invoked locally and on the server
///////////////////////////////
}
[Rpc(SendTo.Server)]
public void InvokeServerSideRpc()
{
InvokeServerAndMe();
}
} The above is the same as using an RPC with a Since there are many ways to accomplish this using the existing API (with minimal script), we will not be adding a Again we value your feedback and hope this doesn't discourage you from providing future suggested feature requests. |
If you are on the server yeah you could just use SendTo.Server. The idea was calling it from the client. |
That is what this script does: public class SomeBehaviour : NetworkBehaviour
{
public void InvokeServerAndMe()
{
if (!IsServer)
{
InvokeServerSideRpc();
}
///////////////////////////////
// Add the the script you want to be invoked locally and on the server
///////////////////////////////
}
[Rpc(SendTo.Server)]
private void InvokeServerSideRpc()
{
InvokeServerAndMe();
}
} When Effectively that is a (You can add whatever parameters you might need to both methods) |
Is your feature request related to a problem? Please describe.
Currently, it's not possible to use the SendTo enum to send to local client and server.
Describe the solution you'd like
I want a syntax like
[Rpc(SendTo.MeAndServer)]
to easily send a request to local client and server.Describe alternatives you've considered
There is a convoluted way to do this using rpcparams, it works and I'm using it as a workaround for now.
rpcParamsMeAndServer = new RpcParams { Send = new RpcSendParams { Target = RpcTarget.Group(new[] { NetworkManager.LocalClientId, NetworkManager.ServerClientId }, RpcTargetUse.Temp) } };
Additional context
The reason I want this is because it's extremely useful when paired with AnticipatedNetworkVariable. When using AnticipatedNetworkVariable, we typically need to run the code on the local client, call anticipate, and send an rpc to the server. Instead, I'm doing this
Since calling Anticipate works on the client and server, effectively I can use the same code. It works like a charm, but would be easier to just have
[Rpc(SendTo.MeAndServer)]
.To summarize, this feature would be specifically useful for AnticipatedNetworkTransform. I don't see why not add it.
The text was updated successfully, but these errors were encountered: