Jump to content

Recommended Posts

Posted

Hello everybody,

 

I'm getting a few unexpected AI behevior when issuing tasks with LUA. As an example, I wrote this simple script to order "a01" to orbit over a trigger:

 

function orbit_task(unit, zone_name, orbit_speed, orbit_altitude)
orbit_zone = trigger.misc.getZone(zone_name).point
orbit_point = {x = orbit_zone.x, y = orbit_zone.z}
	local orbit = {
	id = 'Orbit', 
		params = { 
			pattern = 'Circle',
			point = orbit_point,
			speed = orbit_speed,
			altitude = orbit_altitude,
		} 
	} 
unit:getController():pushTask(orbit)
end

orbit_task(Unit.getByName("a01"), "orbit_zone", 145, 4000)

 

 

In the attached mission, the code is executed after 10 seconds. After 120 seconds I order the aircraft to switch back to waypoint 1, using the in-editor AI TASK PUSH command.

 

The aircraft execute the first command and start orbiting, but the second command has no effect. I tried AI TASK SET, and it doesn’t make a difference.

 

I also tried getController():popTask(), which has no effect, and getController():resetTask(), which sends the aircraft to the closest airport.

 

 

Can anybody help me?

lua_task_test.miz

  • Recently Browsing   0 members

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