Terminator357 Posted 14 hours ago Posted 14 hours ago (edited) Working on a SP mission that encourages the player to move from vehicle to vehicle, either aircraft or ground units. All units still have established waypoints and actions so they can move about and carry out the fight without player involvement, but if the player wants to take control of a tank (or truck, or plane, or heli, or whatever) he can. Problem: ...once you take control of a ground vehicle its AI seems to get tossed out completely. That is to say, if you later exit that vehicle it won't resume its original waypoints or tasks. It just sits there dumb and motionless. I've tried a number of event handler scripts that attempt to push it to one of its original waypoints but they all fail. Using any form of "trigger.action.setCommand(xxxxx)" crashes the game to desktop. "vehicle:getController():setCommand(goToWaypoint)" doesn't error, but doesn't do anything either. Trying to turn the vehicle's AI back on with "vehicle:getController():setOnOff(true)" doesn't change the situation. Planes are no problem since they just RTB and I can deal with that. Ground units are a problem because rogue tanks sitting around the battlefield can mess up other scripts. Somebody else has to have run into this at some point too, how do you guys work around it? Just destroy the vehicle via script and be done with it, or does somebody out there have the magic script that get ground units to resume their original waypoints and task? Thanks in adavance. Below is the lua I'm trying to get to work, but phailing on... local ExitHandler = {} function ExitHandler:onEvent(event) if event.id == world.event.S_EVENT_PLAYER_LEAVE_UNIT and event.initiator ~= nil then local _group = (event.initiator:getGroup()) local goToWaypoint = {id = 'goToWaypoint', params = { fromWaypointIndex = 1, goToWaypointIndex = 2, } } _group:getController():setOnOff(true) --trigger.action.setCommand(_group, 1) -- this just crashes the game _group:getController():setCommand(goToWaypoint) trigger.action.outText("Command sent",10) end end world.addEventHandler(ExitHandler) Edited 14 hours ago by Terminator357 grammar
Recommended Posts