s4m_ur4i Posted December 14, 2017 Share Posted December 14, 2017 I just upgraded to Phaser 2.9.3, since then I get a strange behavior. 1. I press Left / Right to change the Sprite's velocity (x). // See update method 2. Sprite has enabled Physics, World.gravity is 2000 // See in create method 3. But the Sprite instead of moving left (negative velocity.x) moves upwards // See attached gif What I figured out till yet: - velocity.y turn to NaN by colliding with a collisionGroup . - velocity.y stays NaN, even if the character moves into the air. (whyever it moves into air..) There is nothing else going on. I tested this as a test-case, not inside my game, to be sure I'm not messing something up. create method: super(state.game, x, y, 'minions'); this.level = state; this.anchor.setTo(0.5); this.game.physics.arcade.enable(this); this.game.add.existing(this); this.body.bounce.set(0.5); this.body.setSize(45, 110, 80, 45) update method: if(this.controls.on("left")) { this.body.velocity.x = -500; this.animations.play('walk'); } else if(this.controls.on("right")) { this.body.velocity.x = 500; this.animations.play('walk'); } Anyone have a clue why this happens? Thanks in advance. Link to comment Share on other sites More sharing options...
samme Posted December 14, 2017 Share Posted December 14, 2017 Can you post an example? https://codepen.io/samme/pen/vyKJvw And did you update from v2.9.2 or from an earlier version? Link to comment Share on other sites More sharing options...
s4m_ur4i Posted December 14, 2017 Author Share Posted December 14, 2017 Hi, thanks for looking into this. Here's the pen: It's reproducible. (use left / right arrow keys). Seems like velocity x isn't just velocity x. I upgraded from 2.6.2 regards Link to comment Share on other sites More sharing options...
samme Posted December 14, 2017 Share Posted December 14, 2017 Change n.body.gravity = 0; to n.body.gravity.y = 0; // OR n.body.allowGravity = false; s4m_ur4i 1 Link to comment Share on other sites More sharing options...
s4m_ur4i Posted December 14, 2017 Author Share Posted December 14, 2017 You are right. Thanks for the solution and shame on me for overseeing it. I did not know that setting the property on the collision sprites had such an impact. Thanks a lot!Issue solved. Link to comment Share on other sites More sharing options...
Recommended Posts