Jump to content
LSValmont

Getting a position towards the movement of a unit/vehicle?

Recommended Posts

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

Running backwards means speed below zero. So add some conditions for negative speeds.

  • Like 1

Share this post


Link to post
Share on other sites
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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×