≡
Products
▼
Support
▼
Company
▼
Forum
Ambiera Forum
Discussions, Help and Support.
Create a new account
,
Search
, or Login:
Create reply in
Question on multiplayer: are WebSockets useful for creating a multiplayer game?
Posted by:
(you are not logged in)
Enter the missing letter in: "Inte?national"
(you are not logged in)
Text:
[quote][b][/b] wrote: 5, So now you can have multiple states with data stamps. Let's talk only x position for the simplicity it's applied to a rotation same way. So you have 2 snapshots. At 0 ms your player 2 x position is 0 at 100 ms your player 2 position is 10. So for simplicity let's say the player characters moves lineary, there will it be at for example 50 ms? - in the middle of that distance. On 33 ms it will be at 1/3 of the distance. I.e. we can get a position at any time using linear interpolation. The function used to do that is usually called lerp. You can find js implementation of it in the Internet. I guess something like this would work: https://github.com/mattdesl/lerp. [code] // this should be run on every frame // the code sets a position/rotation of the remote player // get current local time first var curTime = (new Date()).getTime(); // use an offset to switch it back to around 100/150ms. This is also a common thing google "source multiplayer networking" for example for details. curTime -= 150; // find first snapshot which past the curTIme var firstSnapshot; // here you look for a first newest snapshot which snaphost.time < curTime var secondSnapshot; // you just take a one with (i - 1) from the firstSnapshot; // you use your lerp function var player2Posx = lerp(firstSnapshot.x, secondSnapshot.x, curTime - secondSnapshot.time); // now you apply it to the player [/code] Sorry I didn't realize it takes that much time to describe:) If you decide to do that and get this far let me know - I'll update the text.[/quote]
Possible Codes
Feature
Code
Link
[url] www.example.com [/url]
Bold
[b]bold text[/b]
Image
[img]http://www.example.com/image.jpg[/img]
Quote
[quote]quoted text[/quote]
Code
[code]source code[/code]
Emoticons
Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact