Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualKylotan

Posted 10 February 2013 - 09:24 AM

My first question is how are server and client-side functions separated if they both need to be called but do different things? For example, collision events would do different things on the server and client, If the client-side actor was autonomous it would play a sound before the server called playSound, but on the server it would tell nearby actors but the current actor to hearSound. How is this achieved?

http://udn.epicgames.com/Three/NetworkingOverview.html#Function call replication

Each program knows its current role, whether as server, client, etc. Certain code only executes when that program is running in that specific role. Servers know to send off function execution to clients if the function is marked for the client.

Just below that part, you have: http://udn.epicgames.com/Three/NetworkingOverview.html#Simulated functions and states

Marking a function with 'simulated' means it's only executed on simulated proxies - on all other roles, it's skipped. It's not strictly about clients and servers - it's about entities on a client that are not controlled by the client. So the 'simulated' functions don't usually make decisions about gameplay, just about presentation (eg. graphical and sound effects).

So basically it's just 2 simple things:
- mark parts of the code as server or client only
- ensure the server sends appropriate messages to the client whenever it encounters some client-only code, to ensure the code is called

In terms of implementation detail, Unrealscript can basically just generate a remote procedure call for each time it sees a function that needs calling on the other side.

The key thing is that there is flexibility in how you implement it. You could choose to have 1 big function for each event that calls out to other smaller functions, and those smaller functions may or may not be implemented on the client or server. Or you might split it up so that you call one client function and one server function, and only the things in the client function will get replicated. There's no right or wrong because it's just 2 routes to 1 goal, ie. getting different bits of script to execute in different places based on process roles.

#2Kylotan

Posted 10 February 2013 - 09:23 AM

My first question is how are server and client-side functions separated if they both need to be called but do different things? For example, collision events would do different things on the server and client, If the client-side actor was autonomous it would play a sound before the server called playSound, but on the server it would tell nearby actors but the current actor to hearSound. How is this achieved?

http://udn.epicgames.com/Three/NetworkingOverview.html#Function call replication

Each program knows its current role, whether as server, client, etc. Certain code only executes when that program is running in that specific role. Servers know to send off function execution to clients if the function is marked for the client.

Just below that part, you have: http://udn.epicgames.com/Three/NetworkingOverview.html#Simulated functions and states

Marking a function with 'simulated' means it's only executed on simulated proxies - on all other roles, it's skipped.

So basically it's just 2 simple things:
- mark parts of the code as server or client only
- ensure the server sends appropriate messages to the client whenever it encounters some client-only code, to ensure the code is called

In terms of implementation detail, Unrealscript can basically just generate a remote procedure call for each time it sees a function that needs calling on the other side.

The key thing is that there is flexibility in how you implement it. You could choose to have 1 big function for each event that calls out to other smaller functions, and those smaller functions may or may not be implemented on the client or server. Or you might split it up so that you call one client function and one server function, and only the things in the client function will get replicated. There's no right or wrong because it's just 2 routes to 1 goal, ie. getting different bits of script to execute in different places based on process roles.

#1Kylotan

Posted 10 February 2013 - 09:21 AM

My first question is how are server and client-side functions separated if they both need to be called but do different things? For example, collision events would do different things on the server and client, If the client-side actor was autonomous it would play a sound before the server called playSound, but on the server it would tell nearby actors but the current actor to hearSound. How is this achieved?

http://udn.epicgames.com/Three/NetworkingOverview.html#Function%20call%20replication

Each program knows its current role, whether as server, client, etc. Certain code only executes when that program is running in that specific role. Servers know to send off function execution to clients if the function is marked for the client.

Just below that part, you have: http://udn.epicgames.com/Three/NetworkingOverview.html#Simulated%20functions%20and%20states

Marking a function with 'simulated' means it's only executed on simulated proxies - on all other roles, it's skipped.

So basically it's just 2 simple things:
- mark parts of the code as server or client only
- ensure the server sends appropriate messages to the client whenever it encounters some client-only code, to ensure the code is called

The key thing is that there is flexibility in how you implement it. You could choose to have 1 big function for each event that calls out to other smaller functions, and those smaller functions may or may not be implemented on the client or server. Or you might split it up so that you call one client function and one server function, and only the things in the client function will get replicated. There's no right or wrong because it's just 2 routes to 1 goal, ie. getting different bits of script to execute in different places based on process roles.

PARTNERS