Jump to content
Sign in to follow this  
Casto

how can i atach a camera to a vehicles

Recommended Posts

well, how can i make a camera inside a driving/flying vehicles and look at the persone who is in the back seat inside the vehicle ??

plzzzz help.

Share this post


Link to post
Share on other sites

This can be achived very easily with a external camera script. By creating a loop that will make the camera stay fixed (or be in movement), in relation to the vehicle:

#Update

_myCam camSetTarget vehicleName

_myCam setSetRelPos [x,y,z]

_myCam camCommit 0

~0.01

goto Update

This will make the camera stay fixed at the X,Y,Z coordinates, relative to the target (in this example; "vehicleName").

Then you can rewrite it, so that you can move the camera around, in the vehicle, while it's moving for example. Then you can add a counter, which keeps track on time, and after a X seconds the script will continue (stop the loop).

If you're not familiar with camera scripting, or not scripting at all, I recommend you to visit OFP editing center's tutorial section. Look for the camera ( "How to script a cutscene" ) tutorial by snYpir.

hmm.. maybe there's another solution?

(Edited by Snake1999 at 5:06 pm on Dec. 27, 2001)

Share this post


Link to post
Share on other sites

all youve done there is target the vehicle. he wants to attatch it. use this script.

; syntax:

; [<name of vehicle>, <name of unit to target>, <[xoffset,yoffset,zoffset]>,<relative to vehicle?>,<time limitation>] exec "vehiclecamV3.sqs"

; example: [heli, dilbert,[0,0,-10],false,300] exec "vehiclecam.sqs"

; get camera vehicle and target

_unit = _this select 0

_target = _this select 1

_timelimit = _this select 4

; define relative time at start of this script

_initialtime=daytime

; you can change the positional offsets for the camera (these are relative to the vehicle)

_camoffsetX = (_this select 2) select 0

_camoffsetY = (_this select 2) select 1

_camoffsetZ = (_this select 2) select 2

; do u want your offsets to be relative to the vehicle?

_camrelative = _this select 3

; clear the variable that will stop this script

vehiclecamstop = false

; create a camera

_cam = "camera" camcreate [0,0,0]

_cam cameraeffect ["internal", "back"]

#loop

; get actual time and calculate the time difference to _initialtime in seconds

_actualtime=daytime

_runtime=(_actualtime-_initialtime)*3600

; now create a loop to continuously update the cam's pos, so it appears to be attached to the vehicle

_newpos = getpos _unit

; set posn not relative to vehicle?

? NOT(_camrelative) : _cam camsetpos [(_newpos select 0) + _camoffsetX, (_newpos select 1) + _camoffsetY, (_newpos select 2) + _camoffsetZ]; goto "commit"

; set posn relative to vehicle

_cam camsettarget _unit

_cam camsetrelpos [_camoffsetX,_camoffsetY,_camoffsetZ]

#commit

; aim camera at target

_cam camcommit 0

_cam camsettarget _target

_cam camcommit 0

; insert a small update time to avoid anychance of any nasty infinity loop errors

~0.005

; perform an if test to see if _stop has been set to true or _uint has been killed: if not, do another lap of the loop

? (NOT(vehiclecamstop) AND (alive _unit) AND (_runtime<_timelimit)): goto "loop"

; the loop ends here when vehiclecamstop gets set to true by either a trigger or a waypoint's "on activation" field once loop had ended, kill the camera and return control to player

TitleCut ["","BLACK OUT",2]

vehiclecamstop = true

~2

_cam cameraeffect ["terminate", "back"]

camdestroy _cam

TitleCut ["","BLACK IN",2]

exit

Share this post


Link to post
Share on other sites

Thanx Rob, but this sounds rather difficult, do you know where i can find a tutorial or a example mission.

Thanx again

Share this post


Link to post
Share on other sites

got one herre waiting for you but it would help if you put your e-mail up on the forum so i can send it without faffing around waiting.

Share this post


Link to post
Share on other sites

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote </td></tr><tr><td id="QUOTE">Quote: from Rob on 6:42 pm on Dec. 27, 2001

all youve done there is target the vehicle. he wants to attatch it. use this script.

; syntax:

; [<name of vehicle>, <name of unit to target>, <[xoffset,yoffset,zoffset]>,<relative to vehicle?>,<time limitation>] exec "vehiclecamV3.sqs"

; example: [heli, dilbert,[0,0,-10],false,300] exec "vehiclecam.sqs"

; get camera vehicle and target

_unit = _this select 0

_target = _this select 1

_timelimit = _this select 4

; define relative time at start of this script

_initialtime=daytime

; you can change the positional offsets for the camera (these are relative to the vehicle)

_camoffsetX = (_this select 2) select 0

_camoffsetY = (_this select 2) select 1

_camoffsetZ = (_this select 2) select 2

; do u want your offsets to be relative to the vehicle?

_camrelative = _this select 3

; clear the variable that will stop this script

vehiclecamstop = false

; create a camera

_cam = "camera" camcreate [0,0,0]

_cam cameraeffect ["internal", "back"]

#loop

; get actual time and calculate the time difference to _initialtime in seconds

_actualtime=daytime

_runtime=(_actualtime-_initialtime)*3600

; now create a loop to continuously update the cam's pos, so it appears to be attached to the vehicle

_newpos = getpos _unit

; set posn not relative to vehicle?

? NOT(_camrelative) : _cam camsetpos [(_newpos select 0) + _camoffsetX, (_newpos select 1) + _camoffsetY, (_newpos select 2) + _camoffsetZ]; goto "commit"

; set posn relative to vehicle

_cam camsettarget _unit

_cam camsetrelpos [_camoffsetX,_camoffsetY,_camoffsetZ]

#commit

; aim camera at target

_cam camcommit 0

_cam camsettarget _target

_cam camcommit 0

; insert a small update time to avoid anychance of any nasty infinity loop errors

~0.005

; perform an if test to see if _stop has been set to true or _uint has been killed: if not, do another lap of the loop

? (NOT(vehiclecamstop) AND (alive _unit) AND (_runtime<_timelimit)): goto "loop"

; the loop ends here when vehiclecamstop gets set to true by either a trigger or a waypoint's "on activation" field once loop had ended, kill the camera and return control to player

TitleCut ["","BLACK OUT",2]

vehiclecamstop = true

~2

_cam cameraeffect ["terminate", "back"]

camdestroy _cam

TitleCut ["","BLACK IN",2]

exit

<span id='postcolor'>

this commands what do they mean,

and what should be inseted on these commands

Share this post


Link to post
Share on other sites

Casto what are you talking about i gave you an example mission via e-m!

Share this post


Link to post
Share on other sites

yep sorry but i think there was al little lag in the mail

cuase i recieved it to day, the 31th.

ps: happy new year every one

Share this post


Link to post
Share on other sites

I got drifted away with this and made rotational, zoom out/in and up/down loop script

Perhaps not any useful as it is, but modified for some purpose it might be wink.gif

_followthis = _this select 0

_camera = "camera" camCreate [6333,9672,14]

_camera cameraEffect ["internal","back"]

_camera camSetFOV 0.850

_roundgo = 0

_distance = 5

_pZ = ((getpos _followthis) select 2) + 2

_godir = 1

_godist = 1

goto "roundwego"

#loop

_camera camsettarget _followthis

goto "zoomwego"

#continue

_camera camsetpos [_pX,_pY,_pZ]

_camera camcommit 0

@camcommitted _camera

~0.01

goto "loop"

#zoomwego

_distance = _distance

?(_distance >= 30) : _godist = 0

?(_distance <= 5) : _godist = 1

?(_godist == 1) : _distance = _distance + 0.02

?(_godist == 0) : _distance = _distance - 0.02

#roundwego

_pX = ((getpos _followthis) select 0) + cos _roundgo * _distance

_pY = ((getpos _followthis) select 1) + sin _roundgo * _distance

?(_roundgo == 360) : _roundgo = 0

_roundgo = _roundgo + 0.5

#vertwego

_pZ = _pZ

?(_pZ >= ((getpos _followthis) select 2) + 5) : _godir = 0

?(_pZ <= ((getpos _followthis) select 2) + -5) : _godir = 1

?(_godir == 1) : _pZ = _pZ + 0.05

?(_godir == 0) : _pZ = _pZ - 0.05

goto "continue"

Share this post


Link to post
Share on other sites

nice one but he has it now! lol :biggrin:

Share this post


Link to post
Share on other sites

Since I got drifted away so much..

I also made timing these things easier - no questimating or calculating, just give commit time in seconds smile.gif

Of course modifiable to many purposes.. like rotate 270 degrees in # seconds.

_followthis = _this select 0

_into = 300

_distance = 500

_timer = 5

_camera = "camera" camCreate (getpos _followthis)

_camera cameraEffect ["internal","back"]

_camera camSetFOV 0.850

_camera camsettarget _followthis

_camera camsetrelpos [_distance,0,2]

_camera camcommit 0

_distance = _distance- _into

_reducedistance = (_distance / _timer) * 0.01

#loop

~0.01

_distance = _distance - _reducedistance

?(_into >= _distance + _into) : exit

_camera camsettarget _followthis

_camera camsetrelpos [_distance + _into,0,2]

_camera camcommit 0

goto "loop"

..very badly drifted away.. oh well, perhaps someone finds use smile.gif

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×