r/howdidtheycodeit • u/Masterofdos • Jul 06 '24
Question How do they code enemies jumping up and down elevation and across gaps to reach the player. You see it in so many games and I'm not sure how it works
95
Upvotes
6
u/Masterofdos Jul 06 '24
In some games enemies will also climb ladders to reach you or climb ladders to reach a ledge they can drop from to reach you. In UT2004 enemies will use movement tech to reach high places quicker. How does the enemy object/actor identify these alternate routes. I know UT2004 uses path nodes for the AI bots but they still need to be told that the impact jump route is there
I'm trying to recreate something like it in 2d (one fewer dimensions to worry about) so I can have a better understanding of pathfinding
89
u/Denaton_ Jul 06 '24
it's called NavMesh Linking
56
u/AdarTan Jul 06 '24
As Recast, an open source navmesh library puts it:
Specific locomotion modes, such as jumping, swimming, crawling under things, climbing ladders, etc. are controlled by special flags in the navmesh polygons. E.g. while traversing through a "ladder" node in the navigation mesh, play the "ladder climb" animation, while parented to the ladder object. These special traversal areas often need to be manually linked to the bigger navmesh that is programmatically generated, but once they are linked they are equally valid, if perhaps uncommonly weighted parts of the navigation graph.
23
u/Saiyoran Jul 06 '24
In Unreal this is fairly simple, you can place NavLinks in a map that allow polygons to act as if they’re touching even if they’re not, and you can tell AI to play an animation (like jumping or climbing) while they traverse the link.
2
u/SynthRogue Jul 26 '24
if (wall.height <= character.height / 2) {character.jump(wall.height);}