TomaszFurca Posted November 5, 2018 Share Posted November 5, 2018 Hi! I think about add path finder to my MMOGame. To do that I want use easystar. I looking for rebuild my scene to grid for pathfinder. it is very simple grid multidimensional array with positions. I just need X and Z, because i do not use Y for movement. So my question is... The best function for detect unwalkable fields (meshes like tree, stone, ground Y<0 AND Y >0) is ray? How i want to do that: Get minX, maxX, minZ, maxZ of my ground. Then loop it for every length (1 vec) and check picked mesh or picked position if I pick ground. Then i can recognize unwalkable position and create grid. Quote Link to comment Share on other sites More sharing options...
ssaket Posted November 5, 2018 Share Posted November 5, 2018 Not Sure! but rather than looping every length(1 vec) as you said, you could loop through other meshes which are inside the scene. And using the boundingBox you can get their min and max X and Z. It's won't be accurate since we'll be using boundingBox but definitely fast. Let's see what others suggest Quote Link to comment Share on other sites More sharing options...
Spankied Posted November 5, 2018 Share Posted November 5, 2018 The best way to do this is to create a navigation mesh on your scene. Then when the user clicks on an area, if the navigation mesh is picked I move the character to that point on the mesh. pointerDown(evt){ let scene = this.scene; let pickResult = scene.pick(scene.pointerX, scene.pointerY); if (pickResult.pickedMesh == scene.getMeshByName("Navmesh")) { this.player.trigger('move', pickResult.pickedPoint.clone()) //player.action } else { this.showActionMenu(pickResult.pickedMesh, scene) } } Heres some resources for baking a nav mesh. https://docs.blender.org/manual/en/dev/game_engine/physics/types/navigation_mesh.html https://www.youtube.com/watch?v=aMWeTXL98mM You can checkout my code here and see demo here. Also, Wanadev created a pathfinding library for babylonjs that uses the A* search algorithm to find a path on a nav mesh. GameMonetize and NasimiAsl 2 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.