OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: Rytuklis on 27 Jan 2013, 15:43:47

Title: How to exit camera loop
Post by: Rytuklis on 27 Jan 2013, 15:43:47
So , i have this camera loop code:

Code: [Select]
#camloop
_camera camsettarget car2
_camera camsetRelpos [0,-5,2]
_camera camcommit 0
goto "camloop"
~15
exit

But it wont exit after 15 seconds. Help :/
Title: Re: How to exit camera loop
Post by: h- on 27 Jan 2013, 16:15:44
Of course not as you have the goto before the time lapse, and even if it was after that it would still not work as you have to make a condition check out of it instead:

One possibility:
Code: [Select]
_i = 0
#camloop
_camera camsettarget car2
_camera camsetRelpos [0,-5,2]
_camera camcommit 0
~0.01
? (_i>=15): exit
_i = _i + 0.01
goto "camloop"

Has been very very long time since I touched sqs so syntax may suck.
If you have to adjust the delay just remember that _i + x has to be the same as the delay value.
Title: Re: How to exit camera loop
Post by: Rytuklis on 27 Jan 2013, 17:09:45
Code: [Select]
; ****************************************************************
; Script file for Armed Assault
; Created by: TODO: Author Name
; ****************************************************************
titleCut ["","BLACK IN",6]

_camera = "camera" camCreate [7409.46,5001.75,53.81]
_camera cameraEffect ["internal","back"]

;=== 16:10:37
_camera camPrepareTarget [-26127.75,-81769.46,-36608.44]
_camera camPreparePos [7409.46,5001.75,53.81]
_camera camPrepareFOV 0.700
_camera camCommitPrepared 8
@camCommitted _camera

_i = 0
#camloop
_camera camsettarget car2
_camera camsetRelpos [0,-5,2]
_camera camcommit 0
~0.01
? (_i>=15): exit
_i = _i + 0.01
goto "camloop"
#endloop

_camera = "camera" camCreate [7415.77,4866.60,1.51]
_camera cameraEffect ["internal","back"]

;=== 16:41:07
_camera camPrepareTarget [-78798.87,55497.38,-1927.45]
_camera camPreparePos [7415.77,4866.60,1.51]
_camera camPrepareFOV 0.700
_camera camCommitPrepared 8
@camCommitted _camera

The code i have^. I used your method, the loop still wouldnt stop.
Title: Re: How to exit camera loop
Post by: Gruntage on 27 Jan 2013, 18:16:33
The problem is probably the way that part of the script has been written. Try changing the order of certain commands around and it might work.

Code: [Select]
_i = 0
#camloop
_camera camsettarget car2
_camera camsetRelpos [0,-5,2]
_camera camcommit 0
_i = _i + 0.01
~0.01
? (_i == 15): exit
goto "camloop"

Try that. As far as I can tell, there isn't anything wrong with that bit of code.
Title: Re: How to exit camera loop
Post by: bedges on 27 Jan 2013, 23:30:11
Use _time. The amount of time it takes a counter to be incremented depends on a lot of things, and requires some calculations to ensure the amount by which the counter is incremented and the number of times it can be incremented within 15 seconds produce the required result - which may be different depending on the system it's running on and what else the engine is doing at the time.

You're looping for a set number of seconds, so why not use _time as the counter?

Code: [Select]
_start = _time
#camloop
_camera camsettarget car2
_camera camsetRelpos [0, -5, 2]
_camera camcommit 0

~0.01

? !(_time >= (_start + 15)) : goto "camloop"

; following code happens after 15 seconds have elapsed

Also, on a more general note, 15 seconds is far too long to stay on a single camera shot, even if it's following a moving vehicle.