Jump to content

Peds movement on path nodes


Thomas_Nightfire

Recommended Posts

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
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.

 

 

 

  • Thanks 1
Link to comment
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
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 by IIYAMA
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...