BEAKSBY 11 Posted June 30, 2014 I would like to createUnit and have it guard that position. If a vehicle tries to run it over or he is shot at, then he should move out of the way but not flee. What is the best way to prevent the soldier from leaving his original position but allow his some room to move, like 5 -10 m maximum. I was planning to write a script that checks if it is fleeing from his original position then forces him to return? "soldierWB" createUnit [getMarkerPos "marker_1", _groupAlpha,"this setUnitPos "UP"; if (soldierWB fleeing) then {this doMove (getMarkerPos "marker_1")}] But this is not working...he either does not move at all or runs away completely. Share this post Link to post Share on other sites
barbolani 198 Posted July 2, 2014 Hi! I see several mistakes here: First, that If has to be in some loop (trigger or scripted), an if condition on init's unit will check right after creating the unit, only once, so when action starts, nothing will happen. You need to put that "If" in a loop. Second: "soldierWB" is not a valid type of soldier in Arma 3. The unit will never create, I'm surprised you say the guy does not move, shouldn't even exist. Check the types list here Third: check fleeing command in wiki, you need an object to refer, so, instead of "soldierWB" which is the type of the unit you created, you need a variable. So instead use this example: Create the soldier: _guardguy = "B_Soldier_F" createUnit [getMarkerPos "marker_1", _groupAlpha]; (not checked syntax, check with createunit command in wiki). Now we can do things with _guardguy, like: _guardguy setUnitPos "UP"; _guardGuy allowFleeing false; _guardguy sideChat "Im bered here, guarding this point"; you see? Explaining in depth the first point: Your "if" statement needs to be in a loop. Why? Because if not, the check will be made only once, if conditions are met, will fire, but in your case, is impossible: _guardguy will never flee right after it's creation, so a loop like this is a must: while {alive _guardguy} do { if (_fleeing _guardguy) then {_guardguy doMove (getMarkerPos "marker_1"} sleep 1; }; Every second this script will check if _guardguy is fleeing, and if yes, the doMove command is issued. If he dies, script is finished. I recommend you a scripting tutorial to understand a bit in depth the way scipting is done. Armaholic has one from Fockers which is really good. Hope I helped! Share this post Link to post Share on other sites
terox 316 Posted July 2, 2014 (group UNITNAME) enableattack false; Share this post Link to post Share on other sites
BEAKSBY 11 Posted July 2, 2014 Hope I helped! You did, much appreciated, Thanks! Share this post Link to post Share on other sites
barbolani 198 Posted July 2, 2014 (group UNITNAME) enableattack false; ¿?¿?¿? thread mistake or I am missing something? Share this post Link to post Share on other sites