[HELP] Spawned ped in plane, how do I throttle forward?

Hey yall!

Was able to revisit my ai testing, and I’m having a bit of trouble getting the ped to throttle forward, I’m currently working within a thread, but the most luck I’ve had was setting the vehicle forward speed (SetVehicleForwardSpeed). The problem with this native is that:

  1. It goes straight to the speed you specify. There’s no gradual throttle
  2. It has to be set every tick for sustenance
  3. If we’re pitching up or something, it’s unrealistic properties maintain the speed despite being in a climb!

I’d like something that’s more gradual that I can set to just (enable throttle from 0 to 1), or (set vehicle throttle) or (throttle forward!).

As you know this is a plane, so some of the driving natives haven’t necessarily been working for me as well.

If there’s any prerequisite to calling a native, please let me know as I’m a bit dry to a lot of these!

Thanks!
-Wet

Anyone have luck with this? I know SOMEONE has a native that I’m missing! Just need some assistance! :grinning_face_with_smiling_eyes:

I did a takeoff from ls airport and land at cayo perico script before, discontinued because the npc pilot sometimes crash landed, maybe you can find something useful from this script, type /planetest to use, it will set you as passenger and the npc pilot will attempt to land at cayo perico, navigating though some static plane entities using TaskPlaneChase, remember to load cayo perico, so the plane won’t land in water

RegisterCommand('planetest', function(source, args)

Citizen.CreateThread(function()

    local vehicleName = 'nimbus'
    if not IsModelInCdimage(vehicleName) or not IsModelAVehicle(vehicleName) then
        return
    end
    RequestModel(vehicleName)
    while not HasModelLoaded(vehicleName) do
        Wait(500)
    end
    local playerPed = PlayerPedId()
    pposd = GetEntityCoords(playerPed)


   local vehicle = CreateVehicle(vehicleName, -1704.0,-2931.0,13.0, 239.0, true, true)

   vehicleb = CreateVehicle(vehicleName, 2925.0,-5600.0,0.0, 236.0, true, true)
   FreezeEntityPosition(vehicleb,true)
   local pposv = GetEntityCoords(vehicleb)

	pname='s_m_y_swat_01'
	    RequestModel(pname)
    while not HasModelLoaded(pname) do
        Wait(500)
    end
	local ped=CreatePedInsideVehicle(vehicle,29,'s_m_y_swat_01',-1,true,true)
	
	Citizen.Wait(1500)

	TaskPlaneChase(ped,vehicleb,vehicleb,vehicleb,pposv.x,pposv.y,pposv.z,9,300.0,0.0,GetEntityHeading(playerPed),2500.0,50.0)

	SetPedIntoVehicle(playerPed, vehicle, 4)
	Citizen.SetTimeout(9000, function()
	SetEntityCoords(vehicleb,2925.0,-5600.0,150.0)
	end)
	Citizen.SetTimeout(32000, function()
	SetEntityCoords(vehicleb,3054.0,-5019.0,61.0)
	end)
	Citizen.Wait(20500)
	ControlLandingGear(vehicle,1)
	
	Citizen.Wait(37000)
	print('ok')
	
	TaskPlaneLand(ped,vehicle,3472.0,-4890.0,30.0,4356.0,-4544.0,4.0)
	
	end)
end,false)
1 Like

Love it, but have some questions after comparing this with the native TaskPlaneChase nativ;

Your example seems to have a LOT of different additional variables attached to them as well; Care to give a breakdown for myself and the other uncultured swine here who don’t understand.

Looking at the documentation, TaskPlaneChase uses:

pilot --[[ Ped ]], 
	entityToFollow --[[ Entity ]], 
	x --[[ number ]], 
	y --[[ number ]], 
	z --[[ number]]

5 arguments
But your example shows:
TaskPlaneChase(ped,vehicleb,vehicleb,vehicleb,pposv.x,pposv.y,pposv.z,9,300.0,0.0,GetEntityHeading(playerPed),2500.0,50.0)

11 Argumentst;
Are you referencing some other form of documentation or was this an old version of the docs that’ve been removed?

Thanks thus far for your help man! It’s been tremendous!

yeah it was my mistake, It got mixed with another plane script that I was testing with TaskPlaneMission, the code I sent before work even with 2 arguments TaskPlaneChase(ped,vehicleb)
as long the plane has a entity to follow it will autopilot and even evade buildings, it can glitch if the followed entity change owner (get near another player)

Gotcha;

I made the changes, and it looks like it started flying as you’ve described. I guess my last challenge is that my server uses custom handling within the plane:
(particularly this: https://www.youtube.com/watch?v=1c0oFtUtYd4)

But I’ve noticed the ped handling the plane as if it was still using the old handling: (Sharp pitch and roll angles).

And lastly, I’ve noticed that the speed seems to not leverage the handling so well; The speed seems to just shoot to whatever the max speed is unfortunately; Do you know of any natives that leverage the vehicle’s natural speed?

If not, it’s cool! Thanks for your help thus far man! :smiley:

Nevermind; I’m using the wrong native! This is perfect! Thanks boss! :smiley:

Hey is there any way to prevent changing network owner of the followed entities? Sometimes my autopilot does not follow the static aircraft’s