[ZScript] A* Pathfinding

Post your example zscripts/ACS scripts/etc here.

[ZScript] A* Pathfinding

Postby dodopod » Thu Oct 12, 2017 6:37 pm

This mod enables A* pathfinding through a network of Nav Points. In order to use it, you'll need to place Nav Points at all the intersections of your map. Connections between Nav Points are generated automatically. Then, create an actor descending from Pathfinder, and use the A_Star function where you would normally use A_Chase. There is a monster and a demo level included (type `map maze` in the console). I recommend using it with `am_cheat 2` so you can see the monster navigating the maze. This is just a prototype, so it isn't terribly optimized, and still has a few problems. Feel free to use or modify it, as long as I'm credited.

Download
dodopod
 
Joined: 04 Oct 2017

Update v0.2

Postby dodopod » Fri Oct 27, 2017 5:03 pm

This update changes pathfinding so that it occurs through a navigation mesh built automatically from the level geometry. At present, the algorithm requires all reachable sectors to be convex polygons, though it tends to work even if they're not. In order to enable pathfinding, inherit an actor from Pathfinder. In addition to a 'See' state, it must also have a 'See.Plan' state. Then add these two action functions:

A_Chase2(StateLabel meleeState = 'Melee', StateLabel rangedState = 'Missile', StateLabel planState = 'See.Plan')

Makes the monster chase its target as long as they are in the same sector, or it has an up-to-date path to its target. Goes in the 'See' state.

Params:
  • meleeState: The state to jump to when the monster decides to perform a melee attack.
  • rangedState: The state to jump to when the monster decides to perform a ranged attack.
  • planState: The state to jump to when the monster doesn't have a path to follow.

A_Star(StateLabel meleeState = 'Melee', StateLabel rangedState = 'Missile', StateLabel seeState = 'See')

Creates a plan to reach the target, or waits if it's unreachable. Goes in the 'See.Plan' state.

Params:
  • meleeState: The state to jump to when the monster decides to perform a melee attack.
  • rangedState: The state to jump to when the monster decides to perform a ranged attack.
  • seeState: The state to jump to when the monster finds a path.

Download
dodopod
 
Joined: 04 Oct 2017

Re: [ZScript] A* Pathfinding

Postby Major Cooke » Sun Feb 11, 2018 1:13 pm

Heh, pretty nice. Shame this doesn't work for maps like this.
User avatar
Major Cooke
The road to Hell is paved in the carrion she leaves behind.
 
Joined: 28 Jan 2007
Discord: Major Cooke#0846

Re: [ZScript] A* Pathfinding

Postby Nash » Sun Aug 05, 2018 12:35 am

Wow, this is interesting!

What would be cool is to see the navmesh build around solid actors (for things like static mesh decorations), and to see chase movement that is velocity-based instead of step-based (so that the monster can smoothly rotate in more than 8 angles and not have stepped movement). :D
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes
Operating System: Windows 10/8.1/8 64-bit
Graphics Processor: nVidia with Vulkan support

Re: [ZScript] A* Pathfinding

Postby ZippeyKeys12 » Tue Feb 12, 2019 11:27 am

Nash wrote:What would be cool is to see the navmesh build around solid actors (for things like static mesh decorations), and to see chase movement that is velocity-based instead of step-based (so that the monster can smoothly rotate in more than 8 angles and not have stepped movement). :D

It'd be better if there was a virtual function called (or first-class functions) that you could control movement from. Then you could decide between the base movement, steering behaviors or whatever your heart desires. Also objects should just be avoided with basic obstacle avoidance like ORCA or RVO, otherwise actors may hit each other in movement or even when one is static.
ZippeyKeys12
 
Joined: 15 Jun 2016


Return to Script Library

Who is online

Users browsing this forum: No registered users and 0 guests