What is the best way to send update peers with appwarp, with minimum lag?

So, what is the best way to send update peers with appwarp? For now in my game, it sends update peers in enterFrame function ( so it is like 60 times in a second ) and when it receives an update it moves the enemy player x and y. And it still does not go smooth.

What I want it to be like is it would send minimum amount of updates and move the enemy player as smooth as possible.

Thank you for your time :slight_smile:

Coder101

My suggestion is to only send deltas (changes) and only when they occur.

If you’re using physics velocities, gravity, etc.  Rely on the physics engine to maintain approximate positions over time, but once a second or more often force an update for critical objects.

Note: I’m just getting up to speed on AppWarp (in my spare [what’s that?]  time) so keep that in mind when reading the following.

Opinion Follows

If you are trying to make a multi-player shooter or action game, I don’t think AppWarp (as you’re using it) or any other peer to peer style game networking solution is suitable.  

Why?  Because if two peers are both making decisions about scores, collisions, death, etc.  You’re bound to get out of sync and have logic conflicts.  This is why traditionally these games are made with client-server logic.  The server is the authority and handles all game logic decisions, as well as updates all clients on their peers’ positions, etc.

Note:  I realize AppWarp says they are good for Multiplayer (MP) games, and they list ‘Authoritative Server’ ((AS) as a feature, but:

  1. I don’t think you’re using these features.

  2. As I understand it, AS implies you’re hosting the game server with them.  This tells me they have a separate or extended API for this.

  3. From what I’ve seen of the API you are using for MP it only seems suitable to turn-based games like card games, puzzles, and/or games that do synchronize score, but not necessarily all game object positions, velocities, etc.

If I find out differently or if someone has a concrete example demonstrating I’m wrong (not the ones on their site), please chime in.

How I have been using appwarp with multiplayer realtime is that I send update peers with variable code which is the update name and then do something accoording to corresponding name. 

For example I send player update peers by  : 

sendupdatepeers ( code = "playerXYUpdate", x = player.x, y = player.y, playerID = playerID )

( the code above probably has errors -> it is just to describe )

And then i have function etc :

if update.code == "playerXYUpdate" and playerID ~= update.playerID then enemyPlayer.x = update.x enemyPlayer.y = update.y end

so the playerID ~= update.playerID checks if the player who sent the update is self or opponent. That is kind of what I have been using, just update.code for different events, I did not make lot of effor explaining this so if you did not get it please ask me and I will feel free to answer you.

So the question is: is there a Corona SDK compatible with some other server - client plugins etc? If it is, compatible with what? And how can I do server logic scripting AND is it possible with the language lua. And is there any possibility to create my own server ( host on my pc ).

Coder101

I get what you said.

Answer: I don’t know of any client-server solutions for Corona. The server would have to be an actual server OR one of the players’ devices, neither of which works well for technical reasons.

More of me talking … :slight_smile:

Again, I’d only send updates on explicit changes, like an explicit change in position or velocity.

For objects influenced by gravity, damping, etc. I would send occasional timed updates.

Also again, I really don’t think this will work well for action games with lots of moving objects and distributed (local to peers) logic.

Sorry if this isn’t the answer you’re looking for.  I wish I had a better one.  I simply don’t know how to do this with guaranteed results w/o a true client-server architecture.

Note: If ‘close enough’ is good enough then no problm

Also, @everyone, surely someone else out there has some experience with this and specifically in the mobile space which is a bit bandwidth and CPU-cycle limited compared to desktop (where the bulk of my MP networking experience is).  Please share your thoughts and insights!

@Coder101,

AppWarp looks pretty cool, so I don’t want to seem like  downer about it.

It’s just that I have coded this kind of thing extensively in the past for desktop games and I know the requirements and limitations of both client-server based MP action games.  So, I’m having trouble believing that the peer-to-peer approach will be capable of keeping your game entities in sync.

Note: I have also experimented with peer-to-peer coding on desktop, but quickly confirmed my opinion that it was unsuitable.

Back to AppWarp.  I am directly investigating this by walking through one of their examples and then making something of my own that is a little more taxing.  

If I have any insights I will share them later.

I forgot to mention, my favorite solution is Coronium.  I still use the older Coronium Cloud and I also like the newer stuff (SkyTable and ChatterBox): 

https://marketplace.coronalabs.com/vendor/67b67c93-ed08-4e75-bf80-0fd7a62b79b6

I could see you doing essentially what you’re doing here, but with ChatterBox.

However, you’d need to set up the server yourself.  This is super easy on DigitalOcean.

My suggestion is to only send deltas (changes) and only when they occur.

If you’re using physics velocities, gravity, etc.  Rely on the physics engine to maintain approximate positions over time, but once a second or more often force an update for critical objects.

Note: I’m just getting up to speed on AppWarp (in my spare [what’s that?]  time) so keep that in mind when reading the following.

Opinion Follows

If you are trying to make a multi-player shooter or action game, I don’t think AppWarp (as you’re using it) or any other peer to peer style game networking solution is suitable.  

Why?  Because if two peers are both making decisions about scores, collisions, death, etc.  You’re bound to get out of sync and have logic conflicts.  This is why traditionally these games are made with client-server logic.  The server is the authority and handles all game logic decisions, as well as updates all clients on their peers’ positions, etc.

Note:  I realize AppWarp says they are good for Multiplayer (MP) games, and they list ‘Authoritative Server’ ((AS) as a feature, but:

  1. I don’t think you’re using these features.

  2. As I understand it, AS implies you’re hosting the game server with them.  This tells me they have a separate or extended API for this.

  3. From what I’ve seen of the API you are using for MP it only seems suitable to turn-based games like card games, puzzles, and/or games that do synchronize score, but not necessarily all game object positions, velocities, etc.

If I find out differently or if someone has a concrete example demonstrating I’m wrong (not the ones on their site), please chime in.

How I have been using appwarp with multiplayer realtime is that I send update peers with variable code which is the update name and then do something accoording to corresponding name. 

For example I send player update peers by  : 

sendupdatepeers ( code = "playerXYUpdate", x = player.x, y = player.y, playerID = playerID )

( the code above probably has errors -> it is just to describe )

And then i have function etc :

if update.code == "playerXYUpdate" and playerID ~= update.playerID then enemyPlayer.x = update.x enemyPlayer.y = update.y end

so the playerID ~= update.playerID checks if the player who sent the update is self or opponent. That is kind of what I have been using, just update.code for different events, I did not make lot of effor explaining this so if you did not get it please ask me and I will feel free to answer you.

So the question is: is there a Corona SDK compatible with some other server - client plugins etc? If it is, compatible with what? And how can I do server logic scripting AND is it possible with the language lua. And is there any possibility to create my own server ( host on my pc ).

Coder101

I get what you said.

Answer: I don’t know of any client-server solutions for Corona. The server would have to be an actual server OR one of the players’ devices, neither of which works well for technical reasons.

More of me talking … :slight_smile:

Again, I’d only send updates on explicit changes, like an explicit change in position or velocity.

For objects influenced by gravity, damping, etc. I would send occasional timed updates.

Also again, I really don’t think this will work well for action games with lots of moving objects and distributed (local to peers) logic.

Sorry if this isn’t the answer you’re looking for.  I wish I had a better one.  I simply don’t know how to do this with guaranteed results w/o a true client-server architecture.

Note: If ‘close enough’ is good enough then no problm

Also, @everyone, surely someone else out there has some experience with this and specifically in the mobile space which is a bit bandwidth and CPU-cycle limited compared to desktop (where the bulk of my MP networking experience is).  Please share your thoughts and insights!

@Coder101,

AppWarp looks pretty cool, so I don’t want to seem like  downer about it.

It’s just that I have coded this kind of thing extensively in the past for desktop games and I know the requirements and limitations of both client-server based MP action games.  So, I’m having trouble believing that the peer-to-peer approach will be capable of keeping your game entities in sync.

Note: I have also experimented with peer-to-peer coding on desktop, but quickly confirmed my opinion that it was unsuitable.

Back to AppWarp.  I am directly investigating this by walking through one of their examples and then making something of my own that is a little more taxing.  

If I have any insights I will share them later.

I forgot to mention, my favorite solution is Coronium.  I still use the older Coronium Cloud and I also like the newer stuff (SkyTable and ChatterBox): 

https://marketplace.coronalabs.com/vendor/67b67c93-ed08-4e75-bf80-0fd7a62b79b6

I could see you doing essentially what you’re doing here, but with ChatterBox.

However, you’d need to set up the server yourself.  This is super easy on DigitalOcean.