Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!   (85,746 visits to this link)

    2. News

    1. GTA Online

      1. Find Lobbies & Players
      2. Guides & Strategies
      3. Vehicles
      4. Content Creator
      5. Help & Support
    2. Crews

      1. Events
      2. Recruitment
    1. Grand Theft Auto Series

    2. GTA Next

    3. GTA V

      1. PC
      2. Guides & Strategies
      3. Help & Support
    4. GTA IV

      1. Episodes from Liberty City
      2. Multiplayer
      3. Guides & Strategies
      4. Help & Support
      5. GTA Mods
    5. GTA Chinatown Wars

    6. GTA Vice City Stories

    7. GTA Liberty City Stories

    8. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    9. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    10. GTA III

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    11. Top Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    12. Wiki

      1. Merchandising
    1. GTA Modding

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    3. Featured Mods

      1. DYOM
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Red Dead Redemption 2

    2. Red Dead Redemption

    3. Rockstar Games

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Programming
      5. Movies & TV
      6. Music
      7. Sports
      8. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Forum Support

    2. Site Suggestions

Sign in to follow this  
VDH-SOFT

[C#] Make vehicles avoid barriers (road blocks)

Recommended Posts

VDH-SOFT

Hi,

 

I would like to know how vehicles will avoid objects like barriers (road blocks) like in LSPDFR mod etc. When I spawn a barrier or more barriers on a road, for example a highway, vehicles will drive into it, it seems like they don't recognize there is a barrier at their path.. Is there any code which make vehicles avoid those barriers? Also, when they drive into a barrier and can't drive further there will become a traffic jam. When I move further away from the barriers the vehicles can literally drive through the barriers and they won't collide anymore.. When I get more close, the vehicles will collide again.

 

How to make the cars avoid the barriers and make them always collide regardless your distance from the barrier?

 

Thanks.

Share this post


Link to post
Share on other sites
VDH-SOFT

Is this such a hard question? Otherwise if nobody knows the answer I will pick a mod which uses roadblocks and decompile it..

Share this post


Link to post
Share on other sites
OfficerJohnson

Is this such a hard question? Otherwise if nobody knows the answer I will pick a mod which uses roadblocks and decompile it..

 

It kinda is. I think you'd be dealing with traffic nodes honestly. Umm, if you know the name of the objects you'll be using, you can script the closest vehicles to "notice" that particular object and then just apply the closest vehicle's brakes or something?

 

Do you get where I'm going with this? Script it so that if the closest vehicle/vehicles have a line of sight on this object, they will brake, freeze or change lanes.

Share this post


Link to post
Share on other sites
VDH-SOFT

@officerjohnson: Yeah I understand you exactly! I thought about that but I haven't found out how I can change the closest vehicle's lane by script.

 

I know LSPDFR mod is using things to make vehicle's avoid road blocks but I cant fully decompile their script, it is obfuscated.

Share this post


Link to post
Share on other sites
Bob_74

Hi,

 

I would like to know how vehicles will avoid objects like barriers (road blocks) like in LSPDFR mod etc. When I spawn a barrier or more barriers on a road, for example a highway, vehicles will drive into it, it seems like they don't recognize there is a barrier at their path.. Is there any code which make vehicles avoid those barriers? Also, when they drive into a barrier and can't drive further there will become a traffic jam. When I move further away from the barriers the vehicles can literally drive through the barriers and they won't collide anymore.. When I get more close, the vehicles will collide again.

 

How to make the cars avoid the barriers and make them always collide regardless your distance from the barrier?

 

Thanks.

What model do you spawn?

I've tried to simply spawn a barrier on the road and vehicles avoid it (ScriptHookVDotNet):

 

World.CreateProp(new Model("prop_mp_barrier_02b"), Game.Player.Character.Position, new Vector3(0f, 0f, 0f), true, true);
EDIT: Same behaviour with prop_barrier_wat_03b, prop_barrier_work01c Edited by Bob_74

Share this post


Link to post
Share on other sites
nm710

Have you tried changing the driving style of the AI, Function.Call(Hash.SET_DRIVE_TASK_DRIVING_STYLE, ped, 32). Check out this guide on driving styles. According to the guide, 32 will avoid objects. You might also want to change drivers ability

PED::SET_DRIVER_ABILITY(Ped driver, float ability).

Edited by nm710

Share this post


Link to post
Share on other sites
OfficerJohnson

Have you tried changing the driving style of the AI, Function.Call(Hash.SET_DRIVE_TASK_DRIVING_STYLE, ped, 32). Check out this guide on driving styles. According to the guide, 32 will avoid objects. You might also want to change drivers ability

PED::SET_DRIVER_ABILITY(Ped driver, float ability).

Right. Totally forgot that Peds have driving tasks.

 

So, OP, what you could do is add code so that when the vehicles get close to this certain prop, you will change their driving ability/task on-the-fly so they AVOID the object.

 

If this is your object and the closest vehicles have a clear line of sight

The closest vehicles will have their driver's ability changed

Or

the closest vehicles to object will have their task set to avoid objects

Share this post


Link to post
Share on other sites
Bob_74

Or try to spawn a prop like I wrote above and tell us if it works for you (works for me, Peds avoid it).

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

×

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.