Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. The Cayo Perico Heist
      2. Find Lobbies & Players
      3. Guides & Strategies
      4. Vehicles
      5. Content Creator
      6. Help & Support
    2. Red Dead Online

      1. Frontier Pursuits
      2. Find Lobbies & Outlaws
      3. Help & Support
    3. Crews

    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. Grand Theft Auto Series

      1. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

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

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
    6. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
    7. GTA III

      1. Guides & Strategies
      2. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

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

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

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

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

      1. GTANet 20th Anniversary
    2. Support

    3. Suggestions

Constrain non-player vehicle to a pre-defined route or path


josiewales

Recommended Posts

josiewales

I would like to have a vehicle going from A-B at a pre-defined speed so that the player car can race against it.

I know how to spawn the vehicle and change its driving style and speed but I do not know how to get it to follow a route or course.
I know that you can add code to get a vehicle to go to a coordinate but is it possible to get it to move to that coordinate via several other coordinates such as the GTAV routes shown here:
https://github.com/gtbikev/courses#grand-theft-bike-v---courses

 

Link to post
Share on other sites

Not exactly sure what you're trying to do, but have you considered a task sequence?

 

For example, in this simple script i defined 4 destinations (think rectangle) to get the peds to go around a track.

 

The other option is you run a DriveTo task and when completed you run another...etc.

 

https://www.youtube.com/watch?v=9zscThwsh1w

 

For a simpler route, why not just:

CurrentPed.Task.DriveTo(LastVehicle, new Vector3(-1278, -3099, 14), 3.0F, 45);

 

or

void TASK_VEHICLE_DRIVE_TO_COORD(Ped ped, Vehicle vehicle, float x, float y, float z, float speed, Any p6, Hash vehicleModel, int drivingMode, float stopRange, float p10) // 0xE2A2AA2F659D77A7 0xE4AC0387 b323

 

Edited by DuncanMac
Link to post
Share on other sites

@DuncanMac Hi. I'm using this code to get a vehicle to go from point A to point B.

Function.Call(Hash.TASK_VEHICLE_DRIVE_TO_COORD_LONGRANGE, Globals.competition_ped, Globals.competition_car, 1739f, 6338f, 35f, 10f, 4 | 16 | 32 | 262144, 10f);

Assuming that 10f relates to the speed and that my GTAV settings are set to metric, does this actually mean that the car is traveling at 10kph ?

The reason I ask is that I am following this car with the player car, the player car is controlled by a real bike and I am doing roughly 35-40km to keep up.

Any ideas ?!

Link to post
Share on other sites
On 6/15/2021 at 4:17 PM, josiewales said:

does this actually mean that the car is traveling at 10kph

Speed returned by GTA V is in meters per second. Multiply by 3.6 to get KPH.

 

If you want to be very specific on the route the car goes, you could probably copy some code from Eddlm's Autosport Racing System mod, which manually controls the vehicle to go the specific route instead of just tasking the ped to drive.

Link to post
Share on other sites
1 hour ago, Jitnaught said:

If you want to be very specific on the route the car goes, you could probably copy some code from Eddlm's Autosport Racing System mod, which manually controls the vehicle to go the specific route instead of just tasking the ped to drive.

 

What's wrong with just breaking up the route into pieces and then using a task sequence. Simpler, no?

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
  • 2 Users Currently Viewing
    0 members, 0 Anonymous, 2 Guests

×
×
  • Create New...

Important Information

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