Recalculation of Navmesh

Hello everybody! does anyone know if there is a way to recalculate the path on navmesh if obstacles are found on the calculated path? for example a building is placed that blocks the path or a dynamic object that closes the short path to the goal and we need to find a new way since you can’t go through the old way anymore

I don’t know if this works in UPBGE, but it does work in 2.79. Here is a short tutorial, it is in German but if you can pick it apart even if you don’t speak German, if you still need help let me know :slight_smile: I have class in 3 minutes so I can’t give you detailed instructions

edit: I know I have found it in English before, I’m just in a rush

1 Like

English tutorial, if your interested. Keep in mind for both videos, object simulation is used for both - which is performance draining.

2 Likes

Idk why the first video that came up for me was in German, lol

This is a good point, there are ways to get around this problem, this is just an easy way to do it with the built in blender tools.

Everything past this point is just a tangent about performance and stuff like that :slight_smile: so read at your own risk.

If I were making something similar I would probably use just the “edit object seek”, but have a check point system instead of a single goal, video games are all about replicating reality but making it fake so the computer can handle it. but it is all dependent on how big your game is, how much you want to optimize it, and your own personal limitations

So a game where there is one entity tracking one single object this calculation system in blender should work just fine, but say you want 50 objects going from separate locations to this single entity it could start putting a drain on your resources (I know my computer would melt trying to do that)

All of that is besides the point, I hope this all helps, and can’t wait to see any games you make :slight_smile:

Fredstash

1 Like

Hi guys! thanks for the info - I appreciate your answers, I know how to work navmesh and simulation of obstacle - the problem is that if I’m in the RTS build 4-5 buildings in a number of an agent located in the middle of one side cannot pass to the target in the opposite direction and is revolving around these buildings as if not knowing which path to choose to bypass, there is still the problem with the U shaped obstacles getting in them, the agent gets stuck and does not know how to get around them, so I wanted to know is there a way to convert the path will navmesh given these obstacles - for example, to blaze a new path (red line) around obstacles,
I will now post an example of where the agent gets stuck so that the problem I encountered is clear

Well your a couple steps ahead of me then, I had to look up the tutorial to figure out how to do object simulations :slight_smile: but I’m still happy to help as much as I can after you post the example.

Are you using BGE or UPBGE?

I use bge version 2.79 and upbge version 0.2.4-0.2.5 because of the presence of components in upbge that are very good to work with and I like how the component works in upbge :slightly_smiling_face:

here in this blend file is the essence of the whole problem of finding a path for RTS in bge and upbge - if you try to send a cube (agent) up or down on a straight line, it will get stuck halfway and will not be able to bypass obstacles navmesh_pathfinding_test.blend (2.7 MB)

Hi thanks for the answer! I uploaded the blend file above to make it clear what I meant when I said recalculating paths-agents get stuck in fairly simple obstacles and I would like to know if it is possible to somehow exclude from the dictionary paths vertices or edges that hit obstacles and find a way around them :slightly_smiling_face:

1 Like

Maybe if the unit has not moved a certain distance for a certain amount of time it triggers and event were the unit chooses a random path in a direction opposite direction and to a random side of the flag, that way it has the highest chance of escaping, and it will keep running this until the player chooses a new location or the unit reaches its goal.

Also how advanced does your pathfinding have to be? could it be an aspect of your game where you build buildings in order to trap the other teams units?

pathfinding is an interesting thing, especially when making an RTS, this is the extent of my thinking, good luck, I’ll keep looking into this, but I don’t know any simple solutions to your problem.

Good luck, and I am excited to see what solutions you come to!

1 Like

Thank you for your kind words, I will try to change the direction of movement of the unit on navmeshu, I have a few ideas how to do this I’m still experimenting but there are situations when the unit does not choose the shortest path or when groups of units prevent each other from passing creating a traffic jam, the best solution would be to write A * path search algorithm but I do not quite understand how to implement it in the game engine

Navigation for an RTS, I’ve been struggling with this for a little while now. I know its not “recalculation of the Navmesh”, but I think have come up with a work-around for myself. (I am unsure of its efficiency for handling large numbers of units.)

Each building has a navigation mesh around itself. When a unit comes close to the building, he switches to use that navigation mesh, and the unit can find their way around the building. When they leave the building’s navigation mesh, he switches back to the “world” navigation mesh.

It’s clear to me this has limited uses, and navigation depends heavily on what mechanics are most important in your RTS, but maybe it can be of some use.

1 Like

Hi thanks for this idea - I will try this option I know there is a way to do it using rayCast () for example -
Zm = o. worldPosition+o. getAxisVect([0,0,-15])
rayZm = o. rayCast(Zm, o, 15,", 0,0,0)
hitZm = rayZm[0]
if hitZm:
if ‘navmesh’ in hitZm:
steering. navmesh = hitZm
I think that I still need to do something to avoid obstacles if the agent finally gets stuck - for example, beam traversal or something like that, it’s a pity that navmesh and the navigation and obstacle simulation system do not rebuild the path when obstacles are detected automatically - but it’s even interesting to find your solution and make it :slightly_smiling_face: :+1:

Greetings.
I know this a year in… I was reading and noticed that there isn’t any suggestion on getting the distance of object(s) to calculate movement.
Hope this helps.

Hi - yes, there is not yet a full-fledged solution for finding the path of units in a real-time strategy, the only thing I came up with is not to use a navigation mesh - replacing it with a flow field, but so far I have not completed this example, although it works quite well, allowing you to immediately send about 40-50 units to the target, getting the distance is also not a problem - dist = own.GetDistanceTo(object, or position)