Page 2 of 2
Re: Example code of Platformer AI
Posted: Mon Mar 22, 2021 10:04 pm
by darkfrei
Gunroar:Cannon() wrote: ↑Mon Mar 22, 2021 8:43 pm
Procedural nap, want the enemy AI to preferably also be able to be used as a player companion. Though just looking for examples. Even java
If too far from player then pathfinding to the player.
Now we are need the pathfinding with jumps
Re: Example code of Platformer AI
Posted: Tue Mar 23, 2021 9:32 am
by Gunroar:Cannon()
Gunroar:Cannon() wrote: ↑Mon Mar 22, 2021 8:43 pm
Procedural nap, want the enemy AI to preferably also be able to be used as a player companion. Though just looking for examples. Even java
Procedural map*, I can have a procedural nap anytime I want.
The closer the example to lua the better, can be any engine, any language though.
I've heard about using pathfinding to get to a point in the map, but with the rules being changed, like don't accept any node without a "solid" node(ground) underneath it, but I don't see how that could work with jumping and velocity calculations.
Re: Example code of Platformer AI
Posted: Tue Mar 23, 2021 7:35 pm
by darkfrei
Gunroar:Cannon() wrote: ↑Tue Mar 23, 2021 9:32 am
I've heard about using pathfinding to get to a point in the map, but with the rules being changed, like don't accept any node without a "solid" node(ground) underneath it, but I don't see how that could work with jumping and velocity calculations.
Some hidden hardcoded jump places, and all you need is a time between two points, actual position and target position.
Re: Example code of Platformer AI
Posted: Wed Mar 24, 2021 8:11 am
by Gunroar:Cannon()
darkfrei wrote: ↑Tue Mar 23, 2021 7:35 pm
Some hidden hardcoded jump places, and all you need is a time between two points, actual position and target position.
Can't hardcode due to procedural map, and thnx for the thoughts, though looking for example code.
Re: Example code of Platformer AI
Posted: Wed Mar 24, 2021 8:38 am
by darkfrei
Gunroar:Cannon() wrote: ↑Wed Mar 24, 2021 8:11 am
darkfrei wrote: ↑Tue Mar 23, 2021 7:35 pm
Some hidden hardcoded jump places, and all you need is a time between two points, actual position and target position.
Can't hardcode due to procedural map, and thnx for the thoughts, though looking for example code.
Ok, not hardcoded, but analysed and cashed; for every block edge jump forward or jump up/down.
Something like ladder (easy for pathfinding), but jumps.
Re: Example code of Platformer AI
Posted: Thu Apr 08, 2021 8:18 pm
by milon
Maybe it's better to think in terms of cached
landing points. Then it doesn't matter if your enemies jump the same height/distance or not. Note that your procedural generator needs to be aware of the enemy's jumping capabilities to create navigable maps, unless you want them getting stuck or diving into pits. Anyway, as it generates maps, it marks the edges (or near-edges) of the pits as landing points. When the enemy wants to path to a different platform, it executes a jump when it's in jump range of that landing point. Jump range would be something you'd have to define per enemy class / AI.
EDIT: You may want to read about Dijkstra maps if you're not already aware.
http://roguebasin.roguelikedevelopment. ... kstra_Maps
This implementation is for a top-down rogue-like, but you can likely tweak it for a platformer. It likely won't have great performance, unless you consider each platform to be its own cell (rather than each pixel).