Ponzu. 132 Posted August 3, 2018 I have a little issue with a script that makes AI chase player in a vehicle, it seem to work if theres only one AI that is a driver but if you add another AI (without adding script to it, just being a gunner) the AI with the script to follow doesn't seem to work? Heres the script: aichase.sqf _unit = _this select 0; _veh = _this select 1; _playerVeh = _this select 2; _unit moveindriver _veh; sleep 1; while {alive _unit} do { _veh setspeedmode "FULL"; _unit move getPos _playerVeh; sleep 0.5; }; ai init Aifollow = [this,c1,a1] execVM "AIchase.sqf"; Everything works well but then stops if additional AI is placed inside the vehicle. So technically what I want to do is have AI in vehicle, chase after players and fire at the from the guns on the vehicle. I know the AI is really stupid when it comes to driving but also is it possible to have them drive to the player a bit closer? they seem to make a lot of distance Share this post Link to post Share on other sites
Grumpy Old Man 3549 Posted August 3, 2018 1 hour ago, Ponzu. said: I know the AI is really stupid when it comes to driving but also is it possible to have them drive to the player a bit closer? they seem to make a lot of distance Well you give them the move command to the players current position, which will always be off. Give the AI vehicle a move command with an estimated position where the player will be, considering the players current speed after a certain time. Quick simplistic example that will make chasing AI try to stay 5m to the right and 25m ahead of the hunted vehicles predicted position considering speed and heading: TAG_fnc_chase = { params ["_hunter","_hunted"]; _chasePositions = [[-5,0,0],[5,0,0]]; _prediction = 5;//will predict hunted position for n seconds considering its speed while {alive _hunter AND alive _hunted} do { _distance = speed _hunted * 0.277778 * _prediction; _predictedPos = (_hunted modelToWorldVisual [5,25,0]) getPos [_distance,getDirVisual _hunted]; _hunter domove _predictedPos; sleep 0.11; }; }; _chase = [hunter,hunted] spawn TAG_fnc_chase; Just keep in mind that a simple 180° turn will outmaneuver the AI, nothing anyone beside BI can do anything about. Cheers 4 Share this post Link to post Share on other sites
Ponzu. 132 Posted August 3, 2018 11 minutes ago, Grumpy Old Man said: Well you give them the move command to the players current position, which will always be off. Give the AI vehicle a move command with an estimated position where the player will be, considering the players current speed after a certain time. Quick simplistic example that will make chasing AI try to stay 5m to the right and 25m ahead of the hunted vehicles predicted position considering speed and heading: TAG_fnc_chase = { params ["_hunter","_hunted"]; _chasePositions = [[-5,0,0],[5,0,0]]; _prediction = 5;//will predict hunted position for n seconds considering it's speed while {alive _hunter AND alive _hunted} do { _distance = speed _hunted * 0.277778 * _prediction; _predictedPos = (_hunted modelToWorldVisual [5,25,0]) getPos [_distance,getDirVisual _hunted]; _hunter domove _predictedPos; sleep 0.11; }; }; _chase = [hunter,hunted] spawn TAG_fnc_chase; Just keep in mind that a simple 180° turn will outmaneuver the AI, nothing anyone beside BI can do anything about. Cheers I'm all new to the idea of scripting those stuff but looking at it makes sense but kinda confused how I get to have it work. What and where do I have to put the params at? Share this post Link to post Share on other sites