Thomas_Nightfire Posted September 12, 2019 Share Posted September 12, 2019 Now I'm just try to understand how NPC HLC Traffic and 'traffic' (default MTA resource) is working, i.e. how the peds choose where to move and where to stop, etc. I know: peds randonly spawn around player on closest nodes and moves to another nodes. Nodes have flags (roadblock, emergency, highway, etc.). Each node have a links to another nodes. But for what a node need a neighbors and links and how it using, I don't know. Can't understand how they choose the right node from others. Please, explain how this system works. I suppose this algorithm has been taken from singleplayer, right? I've read an article at https://gta.fandom.com/wiki/Paths_(GTA_SA) trying to find out, but couldn't... Link to comment
Moderators IIYAMA Posted September 13, 2019 Moderators Share Posted September 13, 2019 17 hours ago, Thomas_Nightfire said: Can't understand how they choose the right node from others. Take a look at this function: https://wiki.multitheftauto.com/wiki/GetDistanceBetweenPointAndSegment2D This function allows you to calculate the shortest distance between a line and a point. If you did that for every line between the notes, you would be able to figure out which one is the closest to your ped or car. 1 Link to comment
Thomas_Nightfire Posted September 14, 2019 Author Share Posted September 14, 2019 8 hours ago, IIYAMA said: Take a look at this function: https://wiki.multitheftauto.com/wiki/GetDistanceBetweenPointAndSegment2D This function allows you to calculate the shortest distance between a line and a point. If you did that for every line between the notes, you would be able to figure out which one is the closest to your ped or car. For what? May be I just need to get the distance between two points? Ped pos and node pos? And my question not about it. It's about traffic system Link to comment
Moderators IIYAMA Posted September 14, 2019 Moderators Share Posted September 14, 2019 (edited) 7 hours ago, Thomas_Nightfire said: And my question not about it. It's about traffic system I only gave you the concept of how traffic resource is doing that. You think you wouldn't find an enchanted version of that same code in the traffic resource? I am pretty sure there is, which is where you could start your search + understanding the code. Edited September 14, 2019 by IIYAMA Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now