OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: SAS4Life on 18 Sep 2006, 12:39:15

Title: cam scripting
Post by: SAS4Life on 18 Sep 2006, 12:39:15
i got a problem with some scripting for a cut scene i dont understand why it wont work. im trying to get the cam to follow a vehicle down the road on a cutscene i arnt getting any error messages it jsut wont work. code is seen below

_Object = _this select 0
_msg = _this select 1

_Count = 0

#loop

_camx = getpos _Object select 0
_camy = getpos _Object select 1
_camz = getpos _Object select 2

;Test
TitleText [_msg,"plain down"]

; Create the camera
_cam = "camera" CamCreate [_camx+5,_camy+5,_camz+5]

;Set the cameras target
_cam CamSetTarget _Object

;Camera Timing
~0.111

; Loop counter
_count = _count + 1

;Has the counter reached its limit
? _count < 5 : goto "loop"

CamDestroy _cam

exit
Title: Re: cam scripting
Post by: bedges on 18 Sep 2006, 16:24:50
the camcreate command is used to create the camera, but to set the camera's position you should use camsetpos (http://www.ofpec.com/COMREF/index.php?action=list&letter=c#camSetPos).

thus your script will look like this -

Code: [Select]
_Object = _this select 0
_msg = _this select 1
_Count = 0

; Create the camera
_cam = "camera" camcreate [0,0,0]
_cam cameraeffect ["internal", "back"]

#loop

_camx = getpos _Object select 0
_camy = getpos _Object select 1
_camz = getpos _Object select 2

;Test
TitleText [_msg,"plain down"]

;Set the camera's target
_cam CamSetTarget _Object

;set the camera position
_cam camsetpos [_camx+5, _camy+5, _camz+5]
_cam camcommit 0
@camcommitted _cam

;Camera Timing
~0.111

; Loop counter
_count = _count + 1

;Has the counter reached its limit
? (_count < 5) : goto "loop"

_cam cameraeffect ["terminate", "back"]
camdestroy _cam

exit
Title: Re: cam scripting
Post by: SAS4Life on 18 Sep 2006, 17:51:39
htanx man that has help loads it really being bugginme also can u make  acam fade out rather then just terminating it if so how?
Title: Re: cam scripting
Post by: Cheetah on 18 Sep 2006, 18:05:02
Code: [Select]
;Has the counter reached its limit
? (_count < 5) : goto "loop"

titleText ["","BLACK OUT",3];
~4

_cam cameraeffect ["terminate", "back"]
camdestroy _cam

exit

Should do the trick.
Title: Re: cam scripting
Post by: SAS4Life on 18 Sep 2006, 18:13:32
works a charm thank you both for ur help cheers
Title: Re: cam scripting
Post by: Chris Death on 18 Sep 2006, 20:21:29
May i suggest another camera command that comes in handy in your case?

Code: [Select]
camera camSetRelPos position
Operand types:
    camera: Object
    position: Array
Type of returned value:
    Nothing
Description:
    Set camera position relative to current position of currect target (see camSetTarget). Does not commit changes.

Example:
    _camera camSetRelPos [10,5]


All you need to do before is to use the camSetTarget command too.

_cam camsettarget vehicle _Object
_cam camsetrelpos [5,5,5]

That would do the same job, just in two lines.  ;)

~S~ CD
Title: Re: cam scripting
Post by: SAS4Life on 14 Jul 2008, 00:09:08
cheers Chris Death

I dont surpose you know if you can pass these as variables rather then hard code them cus i want the camera angle to change everso slightly everytime i refresh it.

Cheers Mate
Title: Re: cam scripting
Post by: Mr.Peanut on 14 Jul 2008, 17:28:49
@SAS. It took you almost two years to read and reply to C-Death's post? He hasn't been to OFPEC since April 10, 2008, 05:17:09 PM. I would not expect a quick reply back from him.

And yes, you can pass them as variables.
Title: Re: cam scripting
Post by: SAS4Life on 14 Jul 2008, 18:50:14
yeh i know i only realised yesterday that i hadnt replyed to him saying thanks and at the same time realised i had a new problem
Title: Re: cam scripting
Post by: Gcfungus on 14 Jul 2008, 20:23:39
Well, if you want to use a variable you can.
Eg.
Code: [Select]
_x = 5
_y = 6
_z = 2
_camera camsetrelpos [_x,_y,_z]

Alternatively, you could use a random function.
Code: [Select]
_x = random 15
_y = random 15
_z = random 15
_camera camsetrelpos [_x,_y,_z]

You might want to play around like adding numbers or multiplying them to the random in order to make them better. The example above could generate 0.0045 or something rediculous, so you might want to play around with it.