Advertisement

Author Topic: Attach a camera to a vehicle  (Read 795 times)

0 Members and 1 Guest are viewing this topic.

Attach a camera to a vehicle
« on: 02 Apr 2007, 10:32:52 »
I was wondering where I could get a script to attach a camera to a vehicle. Preferably so that the camera is not orientated around the center of the vehicle. I searched the forums and did not find a script that worked/ I could work. I need step by step instructions  ;) .

Offline Cheetah

  • Former Staff
  • ****
Re: Attach a camera to a vehicle
« Reply #1 on: 02 Apr 2007, 10:37:21 »
Attaching is pretty easy, but how do you want it orientated?
Like missions? Help with Beta Testing! or take a look at the OFPEC Missions Depot for reviewed missions!

Re: Attach a camera to a vehicle
« Reply #2 on: 02 Apr 2007, 10:40:24 »
An example shot would be to have the camera attached to a jeep with just showing the front grill plate. Maybe a centre axis could work.

Offline bedges

  • Former Staff
  • ****
    • OFPEC The Editing Center
Re: Attach a camera to a vehicle
« Reply #3 on: 02 Apr 2007, 11:47:14 »
investigate blanco's logiccam script. it was written for ofp, and as far as i know hasn't been tested for compatibility with arma. it does exactly what you're describing though, and with a little tinkering should work fine.

Re: Attach a camera to a vehicle
« Reply #4 on: 02 Apr 2007, 12:56:57 »
i read in another thread Blanco had trouble converting the logiccam script. I then looked at this thread:

http://www.ofpec.com/forum/index.php?topic=28949.msg197281#msg197281

and found some things that work. For example, this:

Code: [Select]
_i = 0;
#loop
_camera camPrepareTarget blabla;
_camera camPrepareRelPos [0,-7,2];
_camera camPrepareFOV 0.700
_camera camCommitPrepared 0
~0.01
?(_i == 300): goto "exit";
_i = _i + 1;
goto "loop"

works, but I am unsure of how to control the amount of time the camera is staying place. It seems to stick the vehicle for roughly 5 seconds before becoming 'unlocked'.

Offline hoz

  • OFPEC Site
  • Administrator
  • *****
Re: Attach a camera to a vehicle
« Reply #5 on: 02 Apr 2007, 16:39:26 »
Its the ~0.01 that is refreshing the camera. This is telling the script to hold the loop for a split second and then update.

the line 
Code: [Select]
?(_i == 300): goto "exit";is what is preventing it from being unlocked. What you can do here is once the unit arrives at the WP you could make some variable true like arrival=true
then change the line to read like this...


Code: [Select]
?arrival: goto "exit";
Xbox Rocks

Offline Cheetah

  • Former Staff
  • ****
Re: Attach a camera to a vehicle
« Reply #6 on: 02 Apr 2007, 20:19:01 »
I do have to note that it's not working the way you would expect it to work, at least not in this sqs syntax. With it's current settings you'd expect the camera to stay attached for 300 x 0.01 = 3 seconds. But, as in sqs syntax the ~time doesn't have a priority, it is likely to be more than 0.01 seconds. Let's say 0.03 or any other limit for the SQS syntax that causes the script to run more than three let's say five seconds.

You'd probably get the same result by using ~0.1 instead of ~0.01. Untested though, if the ~time value is high enough (for example ~0.1) you can adjust the _i maximum value (in the example 300) to your desired timeout. Make sure that the refresh time (~0.1) is low enough, 0.1 might actually be too high and could cause a shaky camera. Clear?
Like missions? Help with Beta Testing! or take a look at the OFPEC Missions Depot for reviewed missions!

Offline bedges

  • Former Staff
  • ****
    • OFPEC The Editing Center
Re: Attach a camera to a vehicle
« Reply #7 on: 02 Apr 2007, 21:59:11 »
an alternative would be to use the reserved _time variable, thus:

Code: [Select]
_limit = _time
#loop
_camera camPrepareTarget blabla;
_camera camPrepareRelPos [0,-7,2];
_camera camPrepareFOV 0.700
_camera camCommitPrepared 0
~0.01
?not (_time >= (_limit + however many seconds you want it to last for)): goto "loop";

in this case the ~0.01 is merely used to stop the loop from repeating too fast and sucking up resources. it's the _time comparison which dictates how long it runs for.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Attach a camera to a vehicle
« Reply #8 on: 02 Apr 2007, 22:22:45 »
Beware with _time, last time I checked it in OFP it was reset each time you load a game (If I remember well).

EDIT: it is time, not _time what I'm talking about, no idea what is _time.
« Last Edit: 02 Apr 2007, 23:16:35 by Mandoble »

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re: Attach a camera to a vehicle
« Reply #9 on: 03 Apr 2007, 02:16:23 »
_time is a reserved variable and it holds the time elapsed since a script started.   :yes:


Planck
I know a little about a lot, and a lot about a little.

Offline bedges

  • Former Staff
  • ****
    • OFPEC The Editing Center
Re: Attach a camera to a vehicle
« Reply #10 on: 03 Apr 2007, 09:01:56 »
indeed, nevertheless mandoble's warning is apt in some very rare cases that a game just happens to be saved when a script is mid-way through a loop which relies on a _time comparison. only experimentation would reveal if the value of _time is saved along with the script state.

Offline SaBrE

  • Members
  • *
  • I was once a Llama
    • www.Armed-Assault-Zone.com
Re: Attach a camera to a vehicle
« Reply #11 on: 03 Apr 2007, 12:07:32 »
Bit off-topic but whereabouts of OFPEC can I find a list of all reserved variables?
Can you HELP?

Offline Cheetah

  • Former Staff
  • ****
Re: Attach a camera to a vehicle
« Reply #12 on: 03 Apr 2007, 12:14:38 »
Found a topic about reserved variables and sometimes it's good to know which variables are usable. A few days ago I had trouble with a civilian named - civilian.
Like missions? Help with Beta Testing! or take a look at the OFPEC Missions Depot for reviewed missions!

Offline SaBrE

  • Members
  • *
  • I was once a Llama
    • www.Armed-Assault-Zone.com
Re: Attach a camera to a vehicle
« Reply #13 on: 03 Apr 2007, 13:02:35 »
Looks good, thanks :good:
Can you HELP?

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Attach a camera to a vehicle
« Reply #14 on: 03 Apr 2007, 15:39:49 »
Two confirmed facts in ArmA:
1 - _time is available only for sqs scripts, not for sqf.
2 - time is still reset to 0 after loading any previously saved game (this is quite stupid and disturbing  :blink:).


EDIT:
The safe way to do it in sqf (or sqs) is the following:
Code: [Select]
_timeini = daytime * 3600;
// 30 seconds to wait for something
_waittime = 30;
while {(daytime * 3600) < (_timeini + _waittime)} do
{
.....
};

Code: [Select]
_timeini = daytime * 3600
_waittime = 30
#loop
_camera camPrepareTarget blabla;
_camera camPrepareRelPos [0,-7,2];
_camera camPrepareFOV 0.700
_camera camCommitPrepared 0
~0.01
?((daytime * 3600) < (_timeini + _waittime)): goto "loop";

daytime is correct all the time, even after loading a game.