Jump to content
Sign in to follow this  
Pred42

How to get a friendly AI to follow you?

Recommended Posts

I'm making a mission where you have to rescue a hostage. When you get to him I would like him to follow and get on a heli for the escape. (It would be cool if he could get on a separate heli that I'm not on as well) How would I go about doing this? I know there's a mission someone made that had this feature but I can't find how to do it. Thanks in advance.

Share this post


Link to post
Share on other sites

Give the player a JOIN AND LEAD waypoint at the hostages feet, use the description to change this to 'rescue hostage'. Give the hostage a JOIN waypoint at his own feet and use synchronize (F5) to link the two. The hostage should start to follow the player when they make close contact. Make sure the player is a higher rank to the hostage.

Share this post


Link to post
Share on other sites
waitUntil {_soldier distance _hostage < 10};

[_hostage] joinSilent (group _soldier);

waitUntil {_hostage distance _rescueheli < 30};
[_hostage joinSilent grpNull;
sleep 0.5;

[_hostage joinSilent (group _rescueheli);
_hostage assignasCargo _rescueheli;
[_hostage] orderGetIn true;

Edited by cobra4v320

Share this post


Link to post
Share on other sites

I am feeling slightly defeated by your solution cobra :D

Share this post


Link to post
Share on other sites
I am feeling slightly defeated by your solution cobra :D

Don't worry, we all do at times when he post his great vast knowledge of logic :)

Share this post


Link to post
Share on other sites

Waypoint example I use often, AI follows a point 50m behind player, updated every 10 seconds:

_wp1 = (group _aiUnit) addWaypoint [[0,0,0],0];
   _wp1 setWaypointType "MOVE";
while {alive player} do {
     _wp1 setWaypointPosition [(player ModelToWorld [0,-50,0]), 0];
       (group _aiUnit) setCurrentWaypoint _wp1;
sleep 10;
};

change the condition to whatever you want - most useful with a variable true/false switch.

Share this post


Link to post
Share on other sites
Mattar_Tharkari

Waypoint example I use often, AI follows a point 50m behind player, updated every 10 seconds:

Code:XXX

Pardon my newb, but where does that code go, Mattar?

Share this post


Link to post
Share on other sites
Waypoint example I use often, AI follows a point 50m behind player, updated every 10 seconds:

_wp1 = (group _aiUnit) addWaypoint [[0,0,0],0];
   _wp1 setWaypointType "MOVE";
while {alive player} do {
     _wp1 setWaypointPosition [(player ModelToWorld [0,-50,0]), 0];
       (group _aiUnit) setCurrentWaypoint _wp1;
sleep 10;
};

change the condition to whatever you want - most useful with a variable true/false switch.

What is the reasoning behind using ModelToWorld instead of getpos? Just a question since I can't seem to wrap my head around it :p

OH I get it... easy way to define distance relative from the players model. Great!

Edited by Tuliq

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
Sign in to follow this  

×