Jump to content

Heron

Members
  • Content Count

    6
  • Joined

  • Last visited

Reputation Activity

  1. Like
    Heron reacted to Cudabear in P2JS Collision BUG   
    Hi,
    So the problem is you are moving sprites around by manipulating their X and Y coordinates directly, which physics don't like.  If you move a collision box into another one, it attempts to solve to collision but because the velocity of the colliding box is 0, it doesn't make it easy to solve.  That's why you're seeing this kind of strange behavior.   You should be manipulating the player's body velocity instead of X and Y directly.  You probably don't want to reset the player's velocity each tick, as well.
  2. Like
    Heron reacted to Arcanorum in Name following the player with delay   
    Same problem: 
    Your problem is in Game.js:
    if(game.player.deltaX !== 0 || game.player.deltaY !== 0){ game.player.name.x = game.player.x; game.player.name.y = game.player.y - 50; this.socket.emit("movePlayer", {x: game.player.x, y: game.player.y}); } You should not be moving objects around by manually setting the x/y values in this situation. You should attach the name to the player as a child. In player.js, add player.addChild(player.name); after creating the name text object.
    Also, I wouldn't recommend generating your player ID on the client. Make it on the server when the client connects then send it to them.
    var PlayerID = Math.floor(Math.random() * (999999 - 100000 + 1)) + 100000; Just looks wrong...
×
×
  • Create New...