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

162
Visualizações
How do I move many meshes along different paths at the same speed?

Background

I am creating a game in which you can control multiple people in a community, so obviously, the people need to be able to move on their own, with their own tasks to accomplish. I used the method described in this post about how to move a mesh / object along a path in Three.js. It worked as you can see below but all the people are moving at different speeds than each other. I don't want this.

enter image description here

Question

How do I make them all move at the same speed? And if you have a better solution on how to move a mesh from point to point then please tell me how.

PS: In the post I linked, I used the "fancy movement" part of the answer.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

(In the event the fiddle goes away, the previous answer used a slowly incremented variable with path.getPointAt(position) to move the objects along the path.)

The Curve.getPointAt method takes a value that is a percentage along the curve. Because of this calculation, the distance between points (for example 0 and 0.1) will be different based on the length of the curve.

So if curve1 is 10 units long, and curve2 is 100 units long, then:

curve1.getPointAt(0.1) // vector 1 unit from the start of curve1
curve2.getPointAt(0.1) // vector 10 units from the start of curve2

If you're basing your motion on this, then basically the object moving along curve2 will move 10x as fast as the object moving along curve1.

What you want to do instead is determine how many steps the object should take along a path, given a certain "steps/second" or "steps/frame". This is more aligned to the concept of a real physical velocity, rather than one defined by the length of the path being taken.

Let's say you want to travel at 2 units per frame along curve1 and curve2. Now that you're traveling at a fixed rate, you just need to divide the rate by the total length to get the number of "steps" (or in this case, frames) it will take to reach the end of the path.

2 / 10  = 0.2  // this is the point polling percentage for curve 1
2 / 100 = 0.02 // this is the point polling percentage for curve 2

Now, when you move an object along curve1, you will need to use path.getPointAt(0.2), and for curve2 you will use path.getPointAt(0.02).

Looking ahead a little, you might ask what happens when the math doesn't line up outside a perfect example, and you have extra "partial steps" to make it to the end of the curve. Well, that's up to you to decide how to handle it. You could spend an extra frame to finish the motion, or you could look a step ahead during the movement calculation and decide to just send it to the end.

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