{"name":"doFSM","title":"doFSM","type":"command","url":"https://community.bistudio.com/wiki/doFSM","revid":379414,"updated":"2026-10-31T00:03:21Z","groups":["Unit Control"],"status":"ok","games":{"arma1":"1.00","arma2":"1.00","arma2oa":"1.50","tkoh":"1.00","arma3":"0.50"},"since":"arma1 1.00","arma3_since":"0.50","description":"Orders a unit to process command defined by FSM file (silently).\n\nUnlike with execFSM where *_this* is passed to the FSM, the following parameters are passed when using doFSM/commandFSM:\n\n_leader: leader of subgroup with this command\n_destination: command destination/position\n_target: command target\n_units: list of all persons in subgroup","syntaxes":[{"syntax":"unit doFSM [fsmName, position, target]","params":[{"name":"unit","type":"Object or Array of Objects","type_expr":"Object | Array<Object>"},{"name":"fsmName","type":"String","type_expr":"String"},{"name":"position","type":"Position","type_expr":"Position"},{"name":"target","type":"Object","type_expr":"Object"}],"returns":{"type":"Nothing","type_expr":"Nothing"},"form":"binary","left":{"text":"unit"},"right":{"text":"[fsmName, position, target]"}}],"examples":[{"code":["_soldierOne doFSM [\"move.fsm\", position player, player];"]},{"code":["units player doFSM [\"move.fsm\", position player, player];"]}],"see_also":["FSM","FSM Editor Manual","commandFSM","completedFSM","execFSM","getFSMVariable","setFSMVariable","unitReady"],"notes":[{"user":"Rübe","date":"2010-08-04T16:09:00Z","text":"Do not *doStop* a unit in a FSM called with *doFSM* or *commandFSM*. Doing so nevertheless will halt your FSM, since no links are followed anymore (doing so in an end state should be fine though). Also this may crash your game in certain mysterious circumstances.\n\nYou may design your FSM so that they may be called with doFSM/commandFSM and execFSM likewise by checking if *_units* or *_this* is nil and then init the variables accordingly. Just remember that you should use the low level *moveTo* (together with *moveToCompleted*, *moveToFailed*) if do-/commandFSM'd, and *doMove* or *commandMove* (together with *unitReady*) if execFSM'd. A *moveTo* in an FSM started with *execFSM* won't do anything, likewise *doMove* in a FSM started with *doFSM* or *commandFSM* wont work either. Think about it for a minute and you will see why. (hint: a unit running a FSM called with *doFSM* or *commandFSM* will _never_ return true for *(unitReady _unit)*)\n\nAnyway, if you want to be able to call your FSM either way, a \"ready\" condition might look light this: *(moveToCompleted _unit) || (moveToFailed _unit) || (unitReady _unit)*, assuming you have a *moveTo* or a *doMove* (depending on how the fsm is called) in the prior state."},{"user":"Katulobotomia","date":"2015-02-14T13:36:00Z","text":"Adding to Rübe's note, doFSM can be checked if it has finished by *unitReady* as of 2015 and it will return *true* when your FSM has completed."}]}