example-.io-game
example-.io-game copied to clipboard
Client side player.id is appended with `NaN` after interpolation
Summary:
NaN
is appended to player.id
on the client-side after interpolation. This happens after the second update is received from the server (i.e. the first time interpolation is performed).
Steps to reproduce:
- Add
console.log(me.id);
to the start of therender()
function insrc/client/render.js
. - Start the server with
npm run develop
from the command line. - Visit
localhost:3000
. - Open dev tools (ctrl + shift + j on Windows).
- Join the game by clicking on
PLAY
.
Expected results:
My socket id (e.g. ljLSqzmUSc5ZGEf5AAAC
) is logged to console repeatedly.
Actual results:
- My socket id is logged to console 6 times (e.g.
ljLSqzmUSc5ZGEf5AAAC
). - My socket id appended with
NaN
(e.g.ljLSqzmUSc5ZGEf5AAACNaN
) is logged to console repeatedly.
Additional information:
I encountered this bug when trying to implement a chat feature. Each chat object had a reference to it's parentId
without NaN
appended to it. I was unable to match chat objects to players in the render()
function in src/client/render.js
because the player id's had changed to have NaN
appended to them.