Log in to reply

When I spawn a new car, it won't start accelerating until it's nearly stopped

  • I'm trying to make a mod that creates a new vehicle every 10 seconds, sets the speed/acceleration to match my current vehicle's speed/acceleration, then puts the Player into that new vehicle. So for example if I'm driving Car A at 100m/s, it would spawn Car B with the same speed/acceleration as Car A, then put the player into Car B.

    Creating the new vehicle, setting its speed to match my current speed, and putting the player into it is working, but I can't get the new vehicle to start accelerating properly. Right now I spawn the new vehicle, set its ForwardSpeed to my previous Vehicle's Speed, put the player into it, but then... the car slowly decelerates (no matter what inputs I press), and it only starts accelerating once the car is nearly stopped. It seems like the game refuses to let my new vehicle start accelerating until it is moving at an incredibly low speed - which means I have to wait for the new car to slowly come to a halt for 5+ seconds before I can actually get it to accelerate, which ruins the whole point of maintaining my speed across car spawns.

    I'm not very familiar with the Vehicle mechanics in general so I might be missing something obvious. I've tried setting the new vehicle's Gears, Throttle, Clutch, and RPM to match the previous vehicle's settings, but it still refuses to start accelerating when spawned. In ScriptHookVDotNet there's a Vehicle.Acceleration float, but I can only "get" the value rather than set it.

    Is this just some fundamental restriction on when cars can accelerate in GTA 5, or am I missing something in the code? Any thoughts or advice are appreciated!


    Try using the native to start the engine (and enable the start directly argument, if it exists.)

  • @ikt That works, thank you! Using this native call makes the driver immediately turn on the engine once he's in the new car:

    GTA.Native.Function.Call(GTA.Native.Hash.SET_VEHICLE_ENGINE_ON, myVehicle, true, true, true);

    Weirdly I still can't get the engine to start on its own, this call just makes the driver turn it on himself. Any other combination of the bool parameters still causes the same issue where the engine doesn't start until the car is almost at a complete stop. But with all bools set to true, the driver does the engine starting animation immediately and the car starts accelerating about 1 second later. So technically it's still not "instantly" accelerating but it's very quick now and works great for my purposes.
    Thanks again for the help!

Log in to reply

Looks like your connection to GTA5-Mods.com Forums was lost, please wait while we try to reconnect.