Home   Help Search Login Register  

Author Topic: How to exit camera loop  (Read 2923 times)

0 Members and 1 Guest are viewing this topic.

Offline Rytuklis

  • Members
  • *
How to exit camera loop
« 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 :/

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: How to exit camera loop
« Reply #1 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.
« Last Edit: 27 Jan 2013, 16:17:47 by h- »
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline Rytuklis

  • Members
  • *
Re: How to exit camera loop
« Reply #2 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.

Offline Gruntage

  • Missions Depot
  • Administrator
  • *****
  • How do I get outta this chickensh*t outfit?
Re: How to exit camera loop
« Reply #3 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.
« Last Edit: 27 Jan 2013, 18:18:20 by Gruntage »
"But one thing I can tell you from not just OFP but life in general:  criticism is directly proportional to quality. The more criticism a mission receives, the better the outcome" - macguba

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: How to exit camera loop
« Reply #4 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.
« Last Edit: 28 Jan 2013, 07:34:05 by bedges »