2
\$\begingroup\$

I have created a small experiment in 5.1, a server has an AI character pathfinding around a map over a grid, so its a straight line node to node before it reaches the end.

I would like for the client to also view this pathfinding character.

Using the networking scripts built in it sends fine, however the client see's a stuttering character and not something smooth like the server sees. So my solution to this is that when the server calculates the new node for the character to go to that the location of this node is sent to the client, the client moves its character to the node and so on. So instead of constant transform data being sent, the clients AI can go to the node and wait for the next node location to be sent, therefore being smooth.

In previous versions of Unity I would've used RPC's, but this is labelled as Legacy now, what can I use now to send a node location from the server to the client?

\$\endgroup\$
2
\$\begingroup\$

Reading more into this area I have come across Client RPC calls covered here ... http://docs.unity3d.com/Manual/UNetActions.html

ClientRpc calls are sent from objects on the server to objects on clients. They can be sent from any server object with a NetworkIdentity that has been spawned. Since the server has authority, then there no security issues with server objects being able to send these calls. To make a function into a ClientRpc call, add the [ClientRpc] custom attribute to it, and add the “Rpc” prefix. This function will now be run on clients when it is called on the server. Any arguments will automatically be passed to the clients with the ClientRpc call..

ClientRpc functions must have the prefix “Rpc”. This is a hint when reading code that calls the method - this function is special and is not invoked locally like a normal function.

\$\endgroup\$
  • 1
    \$\begingroup\$ Link-only answers are discouraged on Stackexchange because they quickly fall victim to link rot. Please try to summarize the relevant content in your own words. \$\endgroup\$ – Philipp Jul 2 '15 at 12:05
  • \$\begingroup\$ Edited .. Ive seen alot of link only answers on this site, maybe comment letting me know and if I dnt do it after a while then mark down? \$\endgroup\$ – CH99 Jul 2 '15 at 12:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.