# Bullet range (Phaser 3)

**URL:** <https://phaser.discourse.group/t/bullet-range-phaser-3/7588>\
**Category:** Examples\
**Created:** [October 4, 2020, 7:43pm UTC](https://phaser.discourse.group/t/bullet-range-phaser-3/7588 "2020-10-04T19:43:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![samme](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/samme/32/5275_2.png) [@samme](https://phaser.discourse.group/u/samme)\
**Post date:** [October 4, 2020, 7:43pm UTC](https://phaser.discourse.group/t/bullet-range-phaser-3/7588/1 "2020-10-04T19:43:13Z")

</div>

Here’s a way to make bullets expire at a certain distance traveled, taking advantage of [newVelocity](https://photonstorm.github.io/phaser3-docs/Phaser.Physics.Arcade.Body.html#newVelocity).

It’s a little more efficient to [make bullets expire after a physics-time limit](https://phaser.discourse.group/t/bullet-lifespan-phaser-3/8630) is reached instead. Phaser v3.50.0 will make that easier.

```javascript
function fireBullet (bullet, x, y, vx, vy)
{
    // …
    // Set the range in pixels
    bullet.state = 300;
}

function updateBullet (bullet)
{
    bullet.state -= bullet.body.newVelocity.length();

    if (bullet.state <= 0)
    {
        bullet.disableBody(true, true);
    }
}

```

https://codepen.io/samme/embed/preview/bGpXOZa?default-tabs=js%2Cresult&height=300&host=https%3A%2F%2Fcodepen.io&slug-hash=bGpXOZa
