OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: ahmed117 on 20 Jan 2012, 08:59:25

Title: How to make unit follow?
Post by: ahmed117 on 20 Jan 2012, 08:59:25
Gentlemen,
              I have a mission, in which I want a jeep with MG to guard a truck full of soldiers. For this, I need the jeep to follow the truck. So How can I make that jeep follow that truck without joining its group?
Title: Re: How to make unit follow?
Post by: Gruntage on 20 Jan 2012, 09:21:31
You could do something like this (I'm assuming you want the jeep and truck to not be in the same group?)

Follow.sqs:

Code: [Select]
endwp=false
#LOOP

~1

[jeep1, 1] setWppos getpos truck

? !endwp: goto "LOOP"


This script basically attaches the jeep's waypoint to the truck, and then loops it every second.

To set this up, you need to give your jeep a 'move' waypoint, and synchronise it to a trigger (put 'endwp' in the condition field).

Whenever you want the following to stop, simply make 'endwp' true.

Hope this helps
Title: Re: How to make unit follow?
Post by: ahmed117 on 20 Jan 2012, 09:36:46
I did the same thing but still it does not works, is there something I did wrong?
Title: Re: How to make unit follow?
Post by: Gruntage on 20 Jan 2012, 10:10:54
I'll attach an example mission. Just copy everything you see in the mission, and it should work (you'll need the follow.sqs script which is in the mission folder)
Title: Re: How to make unit follow?
Post by: ahmed117 on 20 Jan 2012, 10:25:12
I got it sir,
              Thank you for creating an example mission for me, actually, the Init trigger I placed, its condition was "this", while your trigger had "true" that is why I had confusion. any way Thank you very much for your help.