OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started 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
-
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 -
_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
-
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?
-
;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.
-
works a charm thank you both for ur help cheers
-
May i suggest another camera command that comes in handy in your case?
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
-
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
-
@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.
-
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
-
Well, if you want to use a variable you can.
Eg.
_x = 5
_y = 6
_z = 2
_camera camsetrelpos [_x,_y,_z]
Alternatively, you could use a random function.
_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.