Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

143
Vistas
How to kill bullet after a certain of distance?

How to kill bullet after a certain amount of time, or certain amount of distance ? I'm using JavaScript and Phaser 3.

if (keyA.isDown && time > lastFired || isDown && time > lastFired) {
          
            var bullet = bullets.create(player.x , player.y, 'bullet');
            
            bullet.setVelocity( -800, 0);
            lastFired = time + 90;

        }
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

If it should be after some time, you could do something like this. (here some more details from the Docs: from the Docs )

But to be honest I don't know, if this would impact the performance, or not.

 ...  
// the 500 ist the timeout in ms
this.time.delayedCall(500, () => bullet.destroy();  
....
(add this line after creating the bullet)

Or you cout use a time event

this.time.addEvent({
    delay: 500,
    callback: ()=>{
        bullet.destroy()
    },
    loop: false
});

for destroying by distance: depending if it is one bullet or many. you could add the bullet to a group and check the distance in the update function, and it its too far you detroy it/them.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda