nicwins Posted May 1, 2017 Share Posted May 1, 2017 Because my bullets are killed via a timer, sometimes the timed intervals differ due to acceleration etc. Can you kill bullets after they have travelled x amount of pixels?? Link to comment Share on other sites More sharing options...
SeelenGeier Posted May 1, 2017 Share Posted May 1, 2017 Save the starting point and then get the distance it travelled. Use the euclidian distance for this: dist((x, y), (a, b)) = √(x - a)² + (y - b)² In your case this would be: Math.sqrt(Math.pow(start.x - now.x, 2) + Math.pow(start.y - now.y, 2)) I am not sure about the formula, looks kinda off Oo. But it should be like this. Link to comment Share on other sites More sharing options...
Milton Posted May 1, 2017 Share Posted May 1, 2017 bullet.lifespan should be exact. Link to comment Share on other sites More sharing options...
samid737 Posted May 1, 2017 Share Posted May 1, 2017 You could do manual distance checking just like @SeelenGeier suggested if you have your own weapon system with varying bullet accelerations. If you are using Phaser.weapon, you could use the bulletKillDistance property: http://phaser.io/docs/2.6.2/Phaser.Weapon.html#bulletKillDistance If your game/world allows it, you could also make a dummy collision body that serves as a wall that automatically destroys bullet oncollision via callbacks. Link to comment Share on other sites More sharing options...
nicwins Posted May 1, 2017 Author Share Posted May 1, 2017 @Milton, what is the syntax for using the lifespan? is it milliseconds? @samid737, I'm going to have a go at these methods tomorrow, will let you know how I go. Thanks Link to comment Share on other sites More sharing options...
nicwins Posted May 1, 2017 Author Share Posted May 1, 2017 I don't use the weapon plugin, as it is just one enemy. The main problem is the initial timing from when it goes from creating bullets to getting from the pool of bullets - so the first bullets seem to last longer than the pooled bullets... Link to comment Share on other sites More sharing options...
Milton Posted May 1, 2017 Share Posted May 1, 2017 44 minutes ago, nicwins said: @Milton, what is the syntax for using the lifespan? is it milliseconds? Yes. Link to comment Share on other sites More sharing options...
Recommended Posts