I'd like to keep track of all the players' positions in an MMORoom, not just for the server to send messages based on AOI, but also for game calculations and such. After a quick browse through the API, I couldn't find any reference to getting a player's position in the MMORoom. Should I just store the position again in the user variables? But that seems to be a little redundant...
So do we have to do:
Client sends new user position to server
Server validates position, and updates MMORoom user position.
Server sets user variables.
Other clients receive updates.
And then for all game calculations we use user variables?
Accessing position in MMORoom
- Flying_Banana
- Posts: 42
- Joined: 04 May 2014, 07:03
Re: Accessing position in MMORoom
It depends... If the position is required as an information on the client side then you can use UserVars, otherwise there's no need for that. You can simply store the position via the User.set/getProperty(...) methods.
Normally you will need the position as UserVars, though. Otherwise how you're going to know where to render the players on screen?
You can take a look at the two examples we have in our Flash Example pack (or Unity example pack). In particular the SpaceWar game.
Hope it helps
Normally you will need the position as UserVars, though. Otherwise how you're going to know where to render the players on screen?
You can take a look at the two examples we have in our Flash Example pack (or Unity example pack). In particular the SpaceWar game.
Hope it helps
Re: Accessing position in MMORoom
I'm running into the same situation of needing to track seemingly redundant data.
I have a custom command for player positional updates which modifies the MMOApi user position and then is broadcast to all clients within the AOI. When another user enters the AOI the PROXIMITY_LIST_UPDATE event on the client contains the MMOApi user position which is used to render the player's initial position and the custom positional update commands are used to update the rendered position while within the AOI.
Where this breaks down in when I need to confirm the player's position on the server side. I could track the user's position as a user property, however there is a findUserLocation call, that appears to expose that data but returns a P3D object who's implementation isn't exposed via the sfs2x libs.
Is it practical for the findUserLocation function to work outside of the lib, or given the "find" reference would it be a more expensive operation then looking up a user property?
I have a custom command for player positional updates which modifies the MMOApi user position and then is broadcast to all clients within the AOI. When another user enters the AOI the PROXIMITY_LIST_UPDATE event on the client contains the MMOApi user position which is used to render the player's initial position and the custom positional update commands are used to update the rendered position while within the AOI.
Where this breaks down in when I need to confirm the player's position on the server side. I could track the user's position as a user property, however there is a findUserLocation call, that appears to expose that data but returns a P3D object who's implementation isn't exposed via the sfs2x libs.
Is it practical for the findUserLocation function to work outside of the lib, or given the "find" reference would it be a more expensive operation then looking up a user property?
Re: Accessing position in MMORoom
Hi,
I would recommend storing the last position of each user on the server side via setProperty(...).
Cheers
no the findUserLocation method will not return anything useful. The P3D class does not deal with physical screen coordinates, instead it keeps track of the sector in which each user is located. These sectors allow to determine which users fall within the AOI of a specific target. That's why none of this is exposed in the API.abush wrote: Where this breaks down in when I need to confirm the player's position on the server side. I could track the user's position as a user property, however there is a findUserLocation call, that appears to expose that data but returns a P3D object who's implementation isn't exposed via the sfs2x libs.
I would recommend storing the last position of each user on the server side via setProperty(...).
Cheers