Home   Help Search Login Register  

Author Topic: cam scripting  (Read 1692 times)

0 Members and 1 Guest are viewing this topic.

Offline SAS4Life

  • Members
  • *
  • Sas4life
cam scripting
« 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

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: cam scripting
« Reply #1 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.

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

Offline SAS4Life

  • Members
  • *
  • Sas4life
Re: cam scripting
« Reply #2 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?

Offline Cheetah

  • Former Staff
  • ****
Re: cam scripting
« Reply #3 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.
Like missions? Help with Beta Testing! or take a look at the OFPEC Missions Depot for reviewed missions!

Offline SAS4Life

  • Members
  • *
  • Sas4life
Re: cam scripting
« Reply #4 on: 18 Sep 2006, 18:13:32 »
works a charm thank you both for ur help cheers

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re: cam scripting
« Reply #5 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
Dont argue with idiots....they will bring you down to their level and beat you there with experience.

How to use Waypoint type Scripted

Offline SAS4Life

  • Members
  • *
  • Sas4life
Re: cam scripting
« Reply #6 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

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: cam scripting
« Reply #7 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.
« Last Edit: 14 Jul 2008, 17:31:57 by Mr.Peanut »
urp!

Offline SAS4Life

  • Members
  • *
  • Sas4life
Re: cam scripting
« Reply #8 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

Offline Gcfungus

  • Members
  • *
Re: cam scripting
« Reply #9 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.
The object of war is not to die for your country, but to make the other bastard die for his.
~George Patton