temporalix Posted January 2, 2015 Share Posted January 2, 2015 I've got npc's that can go offscreen when player moves left/right but as they go out of bounds collision stops working on ground and they end up colliding with the world bounds,what would be the best way to handle them? do i save their positions on outOfBounds? or disable gravity for them or somehow keep ground collisions working out of camera? Link to comment Share on other sites More sharing options...
VizuaaLOG Posted January 2, 2015 Share Posted January 2, 2015 Could you not disable the checkWorldBounds and outOfBoundsKill parameters on the sprite? Link to comment Share on other sites More sharing options...
temporalix Posted January 2, 2015 Author Share Posted January 2, 2015 outOfBoundsKill is set to false and checkWorldBounds is currently set to true as i was testing the possibility of saving and loading position on outOf / in Bounds events. what happens is that the sprites end up losing collision with ground tilesprite when they go out of bounds and then with body.collideWorldBounds as true they collide with the bounds below the ground - http://imgur.com/oozuUSZ . Link to comment Share on other sites More sharing options...
temporalix Posted January 3, 2015 Author Share Posted January 3, 2015 the way that seems to work best is putting this.birdGroup.forEach(function (bird) { if (bird.body.y > 1868) { bird.y = 1866; } });in the update function. so even when the birds go out of camera view and there is no more tilesprite under them to collide with they will stay at the same height so when they do come back into the camera view they are at the right height and can collide with the ground again, they can also continue moving left or right to get into the camera view where the player is. using outOfBounds and OnEnterBounds to fix bird positions leads to glitchy sprites as the events don't happen exactly when sprites leave/enter, setting their gravity in the events also doesn't work and they end up falling down Link to comment Share on other sites More sharing options...
Recommended Posts