LSValmont 789 Posted May 17, 2020 So I have been using this fnc to control the movement of dog agents: vRunnerChargeFeral = { params["_dog","_dogSpawnPos","_runner","_dogTarget"]; _pos = getPos _dogTarget; switch (true) do { case (speed _dogTarget > 2 && speed _dogTarget < 4): {_pos = _dogTarget modelToWorld [0,3,0];}; case (speed _dogTarget > 4 && speed _dogTarget < 6): {_pos = _dogTarget modelToWorld [0,7,0];}; case (speed _dogTarget > 6 && speed _dogTarget < 10): {_pos = _dogTarget modelToWorld [0,12,0];}; case (speed _dogTarget > 10 && speed _dogTarget < 15): {_pos = _dogTarget modelToWorld [0,16,0];}; case (speed _dogTarget > 15): {_pos = _dogTarget modelToWorld [0,20,0];}; default {_pos = _dogTarget modelToWorld [0,1,0];}; }; if (isAgent teamMember _runner) then { _runner moveTo _pos; } else { _runner doMove _pos; }; }; }; The problem is that when the _dogTarget is walking/running backwards the Dogs never reach the target. Is there any way to get a position towards the direction of the movement of a unit instead of the direction of the unit itself? Share this post Link to post Share on other sites
pierremgi 4939 Posted May 17, 2020 Running backwards means speed below zero. So add some conditions for negative speeds. 1 Share this post Link to post Share on other sites
LSValmont 789 Posted May 17, 2020 1 hour ago, pierremgi said: Running backwards means speed below zero. So add some conditions for negative speeds. I did not know that!!! Thank you! I guess this will do: switch (true) do { case (speed _dogTarget < -2): {_pos = _dogTarget modelToWorld [0,-6,0];}; case (speed _dogTarget < 0 && speed _dogTarget > -2): {_pos = _dogTarget modelToWorld [0,-3,0];}; case (speed _dogTarget > 2 && speed _dogTarget < 4): {_pos = _dogTarget modelToWorld [0,3,0];}; case (speed _dogTarget > 4 && speed _dogTarget < 6): {_pos = _dogTarget modelToWorld [0,7,0];}; case (speed _dogTarget > 6 && speed _dogTarget < 10): {_pos = _dogTarget modelToWorld [0,12,0];}; case (speed _dogTarget > 10 && speed _dogTarget < 15): {_pos = _dogTarget modelToWorld [0,16,0];}; case (speed _dogTarget > 15): {_pos = _dogTarget modelToWorld [0,20,0];}; default {_pos = _dogTarget modelToWorld [0,1,0];}; }; Share this post Link to post Share on other sites