How to move mesh by some line/mesh line

Hey guys,

I want to add some liveness to my scene. I want to add some bugs which are moving by some cyclic route. How to create such route in babylon js?

I found such example https://playground.babylonjs.com/#KBS9I5#81 where dude move by some hardcoded points but it looks very unnatural.

Ideal solution for me is to have some imported mesh line and i use bug mesh to move on this line (bug’s face always looking forward by line vector) or to create line mesh in code but with natural angles (such line mesh is possible to create but how to move bug mesh by it?). Is it possible to do this in babylon js? The only thing i found is playground above. Or maybe there is a way to do this better?

Thanks!

Here is the PG with path following - https://playground.babylonjs.com/#1YD970#583
And some documentation - Babylon.js docs

If you need more complex steering behaviors you may consider to use YUKA library - Yuka | Examples with Babylon.js

Thank you very much. it looks like what i need but i found that it uses actual formula to draw a line. it’s a problem i need to draw a line by myself. and from Path3D documantation i found how to do that

Thanks for help

GreasedLineTools:

https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param/greased_line/#finding-the-last-visible-position-on-the-line-when-using-the-visibility-option

3 Likes

Thanks! Greased line looks like more convenient way to work with it but i still need to prepare points for it manually
Thank for help!

1 Like