Jump to content
Joe98

How to delete an individual waypoint with a script

Recommended Posts

I have a soldier with 4 waypoints.  An event has occurred and I wish to delete waypoint number 2.

 

According to the wiki, the command is:  deleteWaypoint [_grp,  2]

 

What do I use in place of:  _grp

.

 

Share this post


Link to post
Share on other sites

The name of the group that owns the waypoint:

 

Quote

deleteWaypoint [group, index]

 

Share this post


Link to post
Share on other sites

So, what is the name of the group?   (I did not name any group)

Share this post


Link to post
Share on other sites

Did you name the soldier? If not than name the soldier, e.g. unit_01. In your script you can then delete the waypoint:

deleteWaypoint [group unit_01, index];

 

Share this post


Link to post
Share on other sites
On 3/3/2020 at 11:30 PM, whiztler said:

Did you name the soldier? If not than name the soldier, e.g. unit_01. In your script you can then delete the waypoint:


deleteWaypoint [group unit_01, index];

 

 

 

I followed that instruction and it does not work.  Rather this command makes the waypoint invisible but the waypoint is still there.  People have posted to the wiki is that the waypoint is still there.

Therefore the command does not seem to work as intended.

.

 

 

 

 

 

Share this post


Link to post
Share on other sites
43 minutes ago, Joe98 said:

Rather this command makes the waypoint invisible but the waypoint is still there.

 

Using waypoints you can see all the waypoints a group has. After running deleteWaypoint you'll see that the group now has one less waypoint. The command definitely removes the waypoint, as I just tested it to delete a unit's waypoint, causing him to respond as expected (by not going to the deleted waypoint).

 

48 minutes ago, Joe98 said:

People have posted to the wiki is that the waypoint is still there.

 

In the link I've posted to the deleteWaypoint command, no one has indicated that in any of the comments. The command should be working fine for you.

Share this post


Link to post
Share on other sites

In my test the waypoint was meant for me.  And the result was described as above.  In your test, I wonder if you tested with AI soldiers.

 

 

Anyhow, from your link to the WIKI in a post dated way back in 2008 even before the GFC:

 

In order to change the behavior of a unit currently following a string of waypoints, it is not enough to use deleteWaypoint. The path of the unit is calculated by the waypoints present at start, and the unit will continue according to the original waypoints even if you delete them by using this command. To achieve the wanted effect, you should rather use setWPPos to the units current position (thereby stopping the unit), and (after a small delay) use deleteWaypoint to remove the waypoints.

Share this post


Link to post
Share on other sites
10 hours ago, Joe98 said:

Rather this command makes the waypoint invisible but the waypoint is still there.

3 hours ago, Joe98 said:

In my test the waypoint was meant for me.  And the result was described as above.

Works fine for me.

_wp1 = group player addWaypoint[ player getPos[ 20, getDir player ], 0 ]; 
_wp2 = group player addWaypoint[ player getPos[ 40, getDir player ], 0 ]; 
_wp3 = group player addWaypoint[ player getPos[ 60, getDir player ], 0 ]; 
 
deleteWaypoint _wp2;

Follow the waypoints and first is at 20m then next is at a further 40m as waypoint 2 has been deleted.

Even a watch line shows the waypoint is deleted.

[[B Alpha 1-1,0],[B Alpha 1-1,1],[B Alpha 1-1,2]]

Where [B Alpha 1-1,0] is the original wp created for any spawned group, and [B Alpha 1-1,1] and [B Alpha 1-1,2] are _wp1 and _wp3 respectively.

waypoints group player apply{ player distance waypointposition _x }
[0,20,60]

No 40m

Share this post


Link to post
Share on other sites

The 4 waypoints have index numbers:  0,1,2,3

 

I wish to delete the second waypoint. I used this in a trigger:

 

deleteWaypoint [group unit_01, 1];

 

How is it faulty?

.

 

 

 

Share this post


Link to post
Share on other sites
6 hours ago, Joe98 said:

I wish to delete the second waypoint.

Second waypoint added to the group? If so that will be index 2, not 1.

Share this post


Link to post
Share on other sites

Right I have changed it to 2 then changed it to 3.    My character continues to go to  ALL  the weaypoints!   

 

The command does not work!

 

My first thought is that I typed the command incorrectly but it seems the command does not work.

.

 

 

 

 

 

Share this post


Link to post
Share on other sites

I just placed a quadbike (driver named "unit_01" with four waypoints in the editor. The waypoints describe a square, with the quadbike moving clockwise around it from the southwest corner. The fourth waypoint is a cycle so the unit will continue around the circuit indefinitely.

After observing the quad drive around the circuit a few times, I executed this code:

deleteWaypoint [unit_01, 1];

This removed the northwest waypoint, making the circuit a right triangle. The quad drove the triangular circuit.
I executed the same code again, thereby removing the northeast waypoint, making the circuit a line segment. The quad drove it as such.

 

I ran the test a few times. Deleting a waypoint while the unit is in transit toward it results in the unit immediately turning to the next waypoint.

It appears the command works as intended. There must be something else going on with your code. Could you share a repro mission that shows the behavior you are seeing?

Share this post


Link to post
Share on other sites

Also, deleteWaypoint is global, so locality shouldn't be an issue, but for the sake of supplying information, what environment are you in (local/hosted/dedi) and how are you executing the command?

Share this post


Link to post
Share on other sites

I am making a single player scenario. Just for testing, the command is done by a trigger before the first waypoint.

 

I started with the command in the trigger:      hint "Trigger ON ON ON";   deleteWaypoint  [group unit_01, 1];

 

The message appears but the waypoint is not deleted.

 

So, today I started again. My intention was to provide a link to my mission.

 

I moved the hint to the back.  The message appeared and this time the waypoint was deleted correctly!

 

I changed the index number and those waypoints were deleted correctly!

 

I then moved the hint to the front again. The waypoints were deleted correctly!  

 

All this implies that I started with a typing error.  At the very beginning, I deleted the command and typed it again. I feel that typing error is not likely and yet it is the only explanation.

 

Thank you to everybody!

 

 

PS:  For longer commands, I have always used Notepad and copy and paste into a init field to avoid typing errors.

.

 

 

 

 

 

 

  • Like 1

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

×