rpiller Posted April 15, 2014 Share Posted April 15, 2014 I'm using SignalR to send player position info to the server 5 times a second (just testing things out). I'm sending player.x & player.y values and when I start the game and don't move it is sending the values just fine. As soon as I move the values stop getting sent. If I just hardcode some numbers that I send then moving doesn't cause this to break so I've concluded it's an issue with player.x & player.y causing some issues (although I see no javascript error in the console). When sending 5, 5 as the values everything works when moving and standing still. The server gets the values as expected. With player.x & player.y when I start up the game they are being sent just fine but the instant I move the server stops getting anything and no javascript error. Any ideas? setInterval(function () { //network.server.setPosition(player.x, player.y); network.server.setPosition(5, 5); }, 200);I'm using P2 physics: game.physics.startSystem(Phaser.Physics.P2JS); My update code: function update() { var action = "stand"; var vel = 100; //layer2.debug = true; player.body.debug = true; player.body.setZeroVelocity(); if (cursors.left.isDown) { player.body.velocity.x = -vel; playerDir = "west"; action = "walk"; } else if (cursors.right.isDown) { player.body.velocity.x = vel; playerDir = "east"; action = "walk"; } else if (cursors.up.isDown) { player.body.velocity.y = -vel; playerDir = "north"; action = "walk"; } else if (cursors.down.isDown) { player.body.velocity.y = vel; playerDir = "south"; action = "walk"; } player.animations.play(playerDir.concat(".", action)); // sort the actors actorLayer.sort();} Link to comment Share on other sites More sharing options...
jflowers45 Posted April 15, 2014 Share Posted April 15, 2014 have you tried putting a console.log before the call to network.server.setPosition to see whether that interval has continued to run Link to comment Share on other sites More sharing options...
rpiller Posted April 15, 2014 Author Share Posted April 15, 2014 Yeah, it looks like it's still going inside the setInterval function but it stops making the call to the server but ONLY when using player.x & player.y and only when I press the cursor keys to move my player. When the values are hardcoded it keeps sending to the server just fine. Link to comment Share on other sites More sharing options...
rpiller Posted April 15, 2014 Author Share Posted April 15, 2014 Figured it out. So I assumed that the player.x/y would always be int. When the game first starts it is an integer value. My RPC on the server is defined as taking integers for x & y. However, as I start moving I see on the javascript side x/y are floats and so it can't fight into the int values so .NET can't find a suitable function to call. Changing my server params to float works now. Why would we get float values for player x/y? I would think it would be in pixels and pixels can really only be int's right? Link to comment Share on other sites More sharing options...
Recommended Posts