Jump to content
Sign in to follow this  
chronicsilence

Set unit waypoint on object in script

Recommended Posts

I have a Darter drone that I create, and I need to set a waypoint on an object for it to move to and follow. This is easy in the editor, but I need to do it dynamically from a script in the mission. This is what I have so far:

_vehicle = createVehicle ["B_UAV_01_F", getMarkerPos "UAV_spawn", [], 10];
createVehicleCrew _vehicle;
_uavGroup = createGroup west;
[_vehicle] join _uavGroup ;
_waypointObject = createVehicle ["B_Soldier_02_f", [3800, 13000, 0], []];

_waypoint = _uavGroup addWaypoint [[0,0,0], 0];
_waypoint waypointAttachObject _waypointObject;
_waypoint setWaypointType "FOLLOW";

systemChat format["Waypoint position: %1", waypointPosition [group _vehicle, currentWaypoint group _vehicle]];

So, with this code one would think that I create a new waypoint with position [0,0,0], then attach that waypoint to the object I want the Darter to move to and follow (and since I attach it to something, the initial creation position shouldn't matter). However, it just results in the "waypoint position" being [0,0,0] and the Darter flying off to the corner of the map.

 

Anyone know what the proper code would be to have the UAV move to and follow the object?

Share this post


Link to post
Share on other sites

You would need to use waypointAttachVehicle, however this command doesn't work on any objects that weren't placed in the editor.

 

The doFollow command might work for what you want though.

Share this post


Link to post
Share on other sites
while {true} do {

 

if (unitName distance UAV > 100) then {

UAV move position unitName;  };

 

    sleep 5;

 

};

Share this post


Link to post
Share on other sites

use this in your script to ensure the wp is set as current wp

_uavGroup setCurrentWaypoint _waypoint;

check the wp position with

_wppos= getWPPos _waypoint;

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  

×