Ya normen, Everytime it is getting waypoint in a path computed by “navi.computePath(model.model_phy.getPhysicsLocation(), debugInfo);”. After that my NPC trying to reach player using those waypoints. “path.addWayPoint(vector);” doesn’t have any meaning here forgot to remove, I added for different purpose. Below are more explanation.
First it is storing initial wayapoint. since my NPC location is same as first waypoint so vector will get 0 and it will go to else part to get the next way point.
second time it will take second way point and after subtracting from NPC position it will give new vector position where my NPC should be. so I am moving my NPC to new position using “npc_phy.setWalkDirection(vector.normalize().multLocal(tpf * 20));”.
Now Repeat step 2 untill it reach my player(sindbad)
This is my understanding, I know some problem in this logic only that’s why I asked. Thanks
youre trying to do way more work than you need to. all you need to do is navMeshPathFinder.setPosition(npcLocation) then do navMeshPathFinder.computePath(playerLocation) this internally creates a list of waypoints in the navmeshpathfinder that the npc would need to reach (in that order) to get to the player without going through walls or obstacles.
you would never do path.addWayPoint() thats a method used by navMeshPathFinder to populate the path for you. all you want to do is read the values in the path so you know which direction sinbad needs to go.
on a sidenote, your usage of CharacterControl is a little… wrong. you might want to just make this work without Bullet (just move shapes around using spatial.move() and spatial.setLocalTranslation() then wants you see how the nav mesh pathfinder works. then go the next step and work with physics.
Hi daniel you are correct. The thing u have mentioned i already defined in my code that is setPosition for NPC and computePath from NPC to my player. I didnt paste whole code here. I pasted only part of it. For “path.addWaypoint()” as I already told, I mentioned this line for different purpose forgot to remove in my post. I was testing the motion path code for that I mentioned path.addWaypoint().
Finally it got fix. Many thanks to all of you. when I am moving NPC without physcis its working fine. I don’t know why my physcis is not moving using “npc_phy.getPhysicsLocation()”. Finally I removed physics from my NPC and did “npc.getLocalTranslation()”, move my NPC and then i applied physcis to it. Anyone who has the same issue do like that.