MauJovi Posted February 17, 2016 Share Posted February 17, 2016 Hi everyone I'm implementing a 3d map with just some squares and I wanna know what's the best way to make a pathfinding algorithm between these squares... My first thought was loading a mesh with just the path, but i'm not sure what will i need to implement and what babylon already has. Can someone give me some tips? I already implemented the A*, but just with divs... Thanks in advance! Quote Link to comment Share on other sites More sharing options...
Suphi Posted February 17, 2016 Share Posted February 17, 2016 maybe some of these may help https://qiao.github.io/PathFinding.js/visual/http://ashblue.github.io/javascript-pathfinding/ https://github.com/qiao/PathFinding.js/ http://www.growingwiththeweb.com/projects/pathfinding-visualiser/ http://www.easystarjs.com/ http://buildnewgames.com/astar/ http://www.briangrinstead.com/blog/astar-search-algorithm-in-javascript MauJovi 1 Quote Link to comment Share on other sites More sharing options...
MauJovi Posted February 17, 2016 Author Share Posted February 17, 2016 First, thank you for your reply. Yeah, I know some of these and, as I said, I already implemented a A* algorithm at http://pathfindingus.hol.es/ My real question is, what's the best way to make my pathfinding algorithm(yeah, I know I'll need a mesh based one) interact with my loaded mesh? Should I use the physics engine included in Babylon or is there a simple way of doing that? Quote Link to comment Share on other sites More sharing options...
Suphi Posted February 18, 2016 Share Posted February 18, 2016 You could raycast to check if the grid is free to walk on or not but i personally would not do that i would have a object like this var collisionData = {}; //add a blocked positioncollisionData[x+"|"+z] = true; //remove a blocked positiondelete collisionData[x+"|"+z] //check if position is blockedif(x+"|"+z in collisionData) MauJovi 1 Quote Link to comment Share on other sites More sharing options...
MauJovi Posted February 18, 2016 Author Share Posted February 18, 2016 Do you mean having an object with the grid of the walkable path? I was wondering doing it with navmesh, like this with Three.js http://nickjanssen.github.io/PatrolJS/demo/demo.html I've researched something with recastjs but i was not able to figure it out how it works. Quote Link to comment Share on other sites More sharing options...
Suphi Posted February 18, 2016 Share Posted February 18, 2016 if you want to check with a ray you could do it like this //length to check higher length would result in less checks but low resolutionvar length = 1;//create a vector3 that points to the right you would need to check all directionsvar right = new BABYLON.Vector3(1, 0, 0);//position of the grid we are currently checking fromvar position = new BABYLON.Vector3(x, y, z);//cast a ray from the position to the right to see if the right is freevar ray = new BABYLON.Ray(position , right, length); var pickingInfo = scene.pickWithRay(ray, function (item) {return item.checkCollisions == true;}); //we return true for meshes that have there checkCollisions set to trueif (pickingInfo.hit){ //the ray hit so its not free to move to the right} more about the ray can be found here http://doc.babylonjs.com/classes/2.3/Ray MauJovi 1 Quote Link to comment Share on other sites More sharing options...
MauJovi Posted February 18, 2016 Author Share Posted February 18, 2016 So, the answer is yes, i'll have to implement my navmesh algorithm checking the collisions right? I thought there was an easier way of doing that since Babylon has a physics framework included. Anyway, thanks for your help! Quote Link to comment Share on other sites More sharing options...
Suphi Posted February 18, 2016 Share Posted February 18, 2016 i'm not aware of something built into babylon but i'm still a noob maybe someone who has more experiences could say if there are any built in classes to help with path finding http://doc.babylonjs.com/classes/2.3 Quote Link to comment Share on other sites More sharing options...
MauJovi Posted February 19, 2016 Author Share Posted February 19, 2016 I'm not expending time trying this right now, cause I have more to do first. I'm just doing researches and everything heads me to implementing my own with the physics engine or using recast.js, but the demos doesn't even work for me and I don't know what i'm doing wrong... Is there some other opinion? UP! Quote Link to comment Share on other sites More sharing options...
jerome Posted February 19, 2016 Share Posted February 19, 2016 AFAIK, there's no built-in path finding function in the BJS framework. You have to use any external library. Quote Link to comment Share on other sites More sharing options...
MauJovi Posted February 25, 2016 Author Share Posted February 25, 2016 anyone? any help? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted February 25, 2016 Share Posted February 25, 2016 This is not a directly related bjs question I'm not really experienced with path finding algorithms Quote Link to comment Share on other sites More sharing options...
MauJovi Posted February 25, 2016 Author Share Posted February 25, 2016 I'll try something loading a mesh only with the path and making logic with its BoundingInfo... may it work? Thanks everyone Quote Link to comment Share on other sites More sharing options...
hunts Posted November 16, 2017 Share Posted November 16, 2017 has anyone tried these libraries with any bjs? On 2/17/2016 at 4:17 PM, Suphi said: maybe some of these may help https://qiao.github.io/PathFinding.js/visual/http://ashblue.github.io/javascript-pathfinding/ https://github.com/qiao/PathFinding.js/ http://www.growingwiththeweb.com/projects/pathfinding-visualiser/ http://www.easystarjs.com/ http://buildnewgames.com/astar/ http://www.briangrinstead.com/blog/astar-search-algorithm-in-javascript 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.