Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

114
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda