Skip to content

NavGO Improved Path Generation with Multi-Raycasting

Latest
Compare
Choose a tag to compare
@DrCampbell2017 DrCampbell2017 released this 29 May 03:33

NavGo Improved Path Generation with Multi-Raycasting

One long standing issue with NavGo has been that connections will be made that are not traversable by characters. This is because the NavGo will check connections from the center of one node to the center of another. So connections will be made in thin gaps or barely around corners. This has now been mitigated by the option of adding multiple Raycast checks between nodes. These additional checks will be made from a specified distance from the center of the node. These paths will ensure greater accuracy for navigation.

This is a Non-Breaking Change

All new components added are optional. NavGo will still function as normal in existing and legacy projects.

Technical Changes

New Test collections:

  • "multitaycast_NavGo_Demo.collection" is the demo for showing multiple raycast support. One character will follow a generated path with 3 rays connecting the nodes instead of just one ray. This insures greater accuracy when generating the map.
  • "multitaycast_NavGo_directional_Demo.collection" is the demo showing that multiple raycast will work cleanly with the directional nodes. Three characters will move around the map. The first will move from directional points 1-8. The second will move from directional points 9-12. The third will explore the full map including directional points 1-8 but not directional points 9-12 as they have been excluded.

NAVGO_HANDLER

Init to the NavGO_HandlerGO

This message sets up the key parameters for the NavGO. It should be called by a main script or the first script loaded in a collection proxy as a way of establishing the algorithm before the nodes spawn in. After initialized, will send a message_id hash("NavGO_Ready") to whatever game object requested the NavGo be initialized.

--Example init message
local message = {}
message.collisions = { hash("wall") } 
message.debug = false
message.deleteNodeAfterGotten = false
message.nodeNeighborRange = 500
message.numberOfRays = 3 --<5> (New / Optional)
message.raduis = 32 -- <6> (New / Optional)
msg.post("/NavGO_HandlerGO#NavGO_HandlerScript", hash("init"), message)

Values:

<5.> message.numberOfRay is an intiger value between 1 and 3. If nil the navGo will assume the value is 1. If less then 1 then the navGo will assume it is 1. If greater then 3 then the system will assume it is 3. Any other value with (including those with a decimal point) will be treated as a 3. This value will be used to determine how many rays will connect each of the nodes. 1 is the normal approach with rays being cast from the center of one node to the center of another. 2 is the wide approach where a ray will be cast from the sides of the node to the sides of another (based upon distance provided by message.raduis). 3 is the combination approach with a ray from the center and the sides of the node.

<6.> message.raduis is a number value. If nil then the navGo will assume the value to be 32. If message.numberOfRay is nil then this variable will be ignored. This value will be used to determine the radius from the center of the node to the side when doing 2 or 3 raycasts.

Set number of rays

This message will change the "number of rays" value within the system. When changed, this value will be used when new nodes are added, when the path is redrawn, or when debug mode is active to show all current connections in the navGo. This message will also preform a call to NAVGO.SET_NUMBER_OF_RAYS and will override any value there.

msg.post("/NavGO_HandlerGO#NavGO_HandlerScript", hash("set_number_of_rays"), { numberOfRays = [put new number of rays value here] }

Set Distance Between Rays

This message will change the "distance between rays" value within the system. When changed, this value will be used when new nodes are added, when the path is redrawn, or when debug mode is active to show all current connections in the navGo. This message will also preform a call to NAVGO.SET_DISTANCE_BETWEEN_RAYS and will override any value there.

msg.post("/NavGO_HandlerGO#NavGO_HandlerScript", hash("set_distance_between_rays"), { raduis = [put new distance value here] })

NavGO_Global

NAVGO.SET_NUMBER_OF_RAYS(numbOfRays)

Will set the 'number of rays' value within the navGo. This call alone will not recalculate the path and will only be used internally when checking for a path to an existing node. This function call will not change the value in the navGo handler.

NAVGO.SET_NUMBER_OF_RAYS(numbOfRays)

This function call alone not automatically recalculate the path, if you need to change the number of nodes when you recalculate a path, message the navGo handler directly thenfollow it with a message to redraw the path otherwise the value will only be used for new nodes / debug purposes and will not effect the current navGo.

msg.post("/NavGO_HandlerGO#NavGO_HandlerScript", hash("set_number_of_rays"), { numberOfRays = [put new number of rays value here] })
msg.post("/NavGO_HandlerGO#NavGO_HandlerScript", hash("redraw_path"))

NAVGO.SET_DISTANCE_BETWEEN_RAYS(distance)

Will set the 'distance between rays' value within the navGo. This will not on it's own recalculate the path and will only be used internally when checking for a path to an existing node and when 'number of rays' is set to 2 or 3. This function call will not change the value in the navGo handler.

NAVGO.SET_DISTANCE_BETWEEN_RAYS(distance)

This function call alone not automatically recalculate the path, if you need to change the distance between rays when you recalculate a path, message the navGo handler directly then follow it with a message to redraw the path otherwise the value will only be used for new nodes / debug purposes and will not effect the current navGo.

msg.post("/NavGO_HandlerGO#NavGO_HandlerScript", hash("set_distance_between_rays"), { raduis = [put new distance value here] })
msg.post("/NavGO_HandlerGO#NavGO_HandlerScript", hash("redraw_path"))