#RPC not working

16 messages · Page 1 of 1 (latest)

acoustic orbit
#

It sounds like you're calling that only for the server with that serverrpc

#

ServerRpc is to run the method on the server.

lavish widget
acoustic orbit
#

It really depends on the rest of your code D: not sure what is going on with those particles

https://fish-networking.gitbook.io/docs/manual/guides/remote-procedure-calls

Here's the guide on RPCs

If the shooting originates from your player you probably need to tell the server you did the shooting and pass along the relevants positions (unless you're doing server-auth which you would then just tell the player you'd like to shoot and then the server does all the rest) So you'd probably do a ServerRpc to tell the server about the shooting, or the shooting request

Once the shooting has been decided that it's happening, either way, you probably want to do a ObserversRpc from the server to tell everyone else about the shooting and handle it for each observer. Keep in mind that clients can't send rpcs to other clients, only the server can. So you need the server to call that rpc.

lavish widget
autumn merlinBOT
#

Gave +1 Rep to @acoustic orbit

sharp atlas
#

Hey this is something I can help with finally

#

What I am trying to do on my project is have the shoot animation client side, then send a server rpc and do validation the player can shoot and then after do an observer rpc to show everyone else

#

Currently this is how I have it setup and it's working but I'm looking into if there's any issues with this method aka hacking

#

With this method, I think the biggest thing is making sure the player doesn't shoot too fast

#

So if they wanted to use cheat engine and shoot a billion rounds with speed hack, it would show that client side, but the server could detect they're trying to shoot too fast and correct it or just kick them

#

And other players would never see it

sullen solar
#

@lavish widget

#
    {
if(isOwner == true){
       Internal_Shoot(); //play particle on owner instantly to hide latency
       CmdShoot();
}    }


    [ServerRpc]
    void CmdShoot()
    { 
        //validate shooting here to check for hacks/cheats etc   
        if(CanShoot() == true)
        {
            RpcShoot();
        }
    }

    [ObserversRpc]
    void RpcShoot()
    {
       if(isOwner == true) return; //if owner do not play 

       Internal_Shoot();
    }

void Internal_Shoot()
{
        particles.transform.position = particlePos.transform.position;
        particles.transform.eulerAngles = player.transform.eulerAngles;
        particles.Play();
}```
#

try this

#

pseudo code