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

116
Vistas
MatterJS precompute final position

I am trying to create a simple 2D game where a ball is falling to the ground, influenced by some obstacles that will change the final position of the ball.

I am using MatterJS as a 2D physics engine but it is actually unpredictable, with the same parameters my ball is always at a different final position.

Is there a way to precompute the path the ball will have (instantly), save it into a variable and load it to get the exact same path whenever I need it? Or is there a way to predict the final position accurately?

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

0

I found a way to precompute instantly the path of the ball by calling manually Matter.Engine.update(engine) and storing the position of my ball for each frame.

Then i reset the position of my ball, set ball.isStatic = true; and move it manually at each frame:

Matter.Events.on(engine, "afterUpdate", () => {
    if (positions.length > 0) {
        Matter.Body.setPosition(ball, positions.shift());
    }
});
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