zargap Posted February 8, 2014 Share Posted February 8, 2014 Hi friends, new to the forum and to Phaser. Basically I'm trying to get my bearings and right now I'm just sorta turning the "Making your first Phaser game" tutorial http://www.photonstorm.com/phaser/tutorial-making-your-first-phaser-game into a more RPG-style dealy. My issue is that my sprite-to-sprite collisions seem to be working well, but if say I walk into a sprite headed right, bump into another sprite and then go a bit up or a bit down, sometimes I can continue through the sprite by heading further right.I don't have this problem with tileset collisions. Here's what I have for movement: //LEFT if (cursors.left.isDown) { if (player.body.touching.left) { player.x += 3; } else { player.body.velocity.x = -100; player.animations.play('left'); }//RIGHT } else if (cursors.right.isDown) { if (player.body.touching.right) { player.x -= 3; } else { player.body.velocity.x = 100; player.animations.play('right'); }//UP } else if (cursors.up.isDown) { if (player.body.touching.up) { player.y += 3; } else { player.body.velocity.y = -100; player.animations.play('stand'); }//DOWN } else if (cursors.down.isDown) { if (player.body.touching.down) { player.y -= 3; } else { player.body.velocity.y = 100; player.animations.play('stand'); } } /*else if (cursors.up.isUp) { player.body.velocity.y = 0; player.animations.stop(); } else if (cursors.down.isUp) { player.body.velocity.y = 0; }*/ else { // Stand still player.animations.stop(); player.frame = 4; player.body.velocity.x = 0; player.body.velocity.y = 0; } }And for collisions: game.physics.collide(player, mans); Is it something I did? Am I doing something really inelegant and unnecessary or something? Should I add something with overlaps? Thanks in advance. Link to comment Share on other sites More sharing options...
zargap Posted February 8, 2014 Author Share Posted February 8, 2014 Also, seems that if I bump into another sprite enough I can walk through it. Seems to be something with the sprites not registering as touching? Link to comment Share on other sites More sharing options...
alvatar Posted February 8, 2014 Share Posted February 8, 2014 I'm having an issue that might be related. I've just posted it but I need approval, as it is my first post. Link to comment Share on other sites More sharing options...
jcs Posted February 9, 2014 Share Posted February 9, 2014 try using velocity to move the sprites instead of directly manipulating their position - I believe directly changing their position overrides the physics engine and collision handling won't work properly Link to comment Share on other sites More sharing options...
zargap Posted February 9, 2014 Author Share Posted February 9, 2014 Thanks jcs, I tried that but the problem persists. :'( It seems like if say the right edge of a sprite body is touching the left edge of another it doesn't register them as "touching." Link to comment Share on other sites More sharing options...
jcs Posted February 9, 2014 Share Posted February 9, 2014 ah, is this in v1.1.4? Link to comment Share on other sites More sharing options...
alvatar Posted February 9, 2014 Share Posted February 9, 2014 I had this similar issue in v1.1.3 as well. Please see: http://www.html5gamedevs.com/topic/3677-interacting-sprites-with-physics-overlap-and-shouldnt/ Link to comment Share on other sites More sharing options...
Kobaltic Posted February 9, 2014 Share Posted February 9, 2014 Why are you moving the sprite when it is touching instead of checking for a collide and letting the physics engine handle it? Link to comment Share on other sites More sharing options...
alvatar Posted February 9, 2014 Share Posted February 9, 2014 He is probably doing that because the Physics engine fails to guarantee that the sprites won't ever overlap. Link to comment Share on other sites More sharing options...
jcs Posted February 9, 2014 Share Posted February 9, 2014 1.1.3 (and previous) had issues where sprites could be forced into each other and into tiles if "pushed hard enough". if you search the forums you'll find threads on this issue. the physics in 1.1.4 was re-written to fix this. unfortunately, at present, issue #362 means that some collisions don't seem to happen at all. Link to comment Share on other sites More sharing options...
zargap Posted February 9, 2014 Author Share Posted February 9, 2014 Yes, this is in 1.1.4. If I don't have the bit that checks if they're touching and bumps the sprite a bit, it's a lot easier to just walk through things, but I guess I'll just take that out and wait for it to get fixed, thanks for clearing this up (more or less). Link to comment Share on other sites More sharing options...
alvatar Posted February 13, 2014 Share Posted February 13, 2014 Seems fixed in 1.1.5 Link to comment Share on other sites More sharing options...
zargap Posted February 13, 2014 Author Share Posted February 13, 2014 Hooray, looks like it is! Link to comment Share on other sites More sharing options...
Recommended Posts