OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: tehhunter on 02 Jul 2005, 04:40:53

Title: Holding a specific direction
Post by: tehhunter on 02 Jul 2005, 04:40:53
Hey everybody,
I'm relatively new to the OFPEC forums and OFP scripting, but I am experienced in scripting with higher level things.

So anyhoo, I am trying to make a speech by an officer in which many columns/rows of troops stand at attention to the speech.

My problem is that I have tried using this in the unit init:

this setDir 0; doStop this

While the unit does not move,  I find they will change their direction randomly. Some will face the way I specify (probably just randomly), and some will look off nowhere.

Is there any way to make sure they do not change direction once they have been created?
Title: Re:Holding a specific direction
Post by: THobson on 02 Jul 2005, 07:28:31
This is real pain.  Here is a script I have written to keep them facing in a specific direction.  It is still not perfect, I am looking at doing something similar to stop them turning their heads.  I know what to do I just haven't got round to it yet.  Basically just make them watch a point that is a long way away.

Code: [Select]
;KeepFacing.sqs
;This script keeps a unit facing in a specified direction for a specified length of time
;called by:  [unit,direction,time] exec "KeepFacing.sqs"

_unit = _this select 0
_dir = _this select 1
_duration = _this select 2


#loop
~0.01
_unit setDir _dir
if (_time < _duration) then {goto"loop"}
exit

Title: Re:Holding a specific direction
Post by: Morglor9 on 02 Jul 2005, 09:06:43
if u don't need the guys to move later (like in a cutscene) use:

Code: [Select]
dude setdir (whatever you want)
dude disableAI "MOVE"
Title: Re:Holding a specific direction
Post by: h- on 02 Jul 2005, 12:47:28
The problem comes from doStop which is completely bug ridden (= BISd ::) )...
Usually it forces the unit to watch at 0 (north) but it seems that sometimes some another direction is 'selected'... Probably when the unit is already facing 0 ::)

I've always used a bit similar method like THobson's script above does...