OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Blanco on 20 Feb 2004, 18:17:43
-
_gl1 = "logic" camcreate getpos plane
_gl2 = "logic" camcreate getpos plane
_camera = "camera" camcreate [0,0,0]
_camera cameraeffect ["internal","back"]
_xpos = 0
_ypos = -90
_zpos = 0
_xpos2 = 0
_ypos2 = +50
_zpos2 = 0
_camera camsetpos getpos _gl1
_camera camsettarget _gl2
_camera camcommit 0
camcommitted _camera
#loop
_gl1 setpos [(getpos plane select 0) + _xpos2*sin(getdir plane),(getpos plane select 1) + _ypos2*cos(getdir plane),(getpos plane select 2) +_zpos2]
_gl2 setpos [(getpos plane select 0) + _xpos*sin(getdir plane),(getpos plane select 1) + _ypos*cos(getdir plane),(getpos plane select 2) +_zpos]
_camera camsetpos getpos _gl2
_camera camsettarget _gl1
_camera camcommit 0
goto "loop"
I know the loop is too fast..but...
this is cam that follows a plane from the rear but it's not focusted (camsettarget-ed) on the plane itself.
Everything works fine when it's flying from N to S or from S to N, but it's all messed up when the plane start to turn to W or E...
What do I have to change to keep them (_gl1 & _gl2) in (relative) position from the plane?
I hope you understand my Q :-\
-
uhm...you use mathematics in there which i can't understand ;D
but take a closer look about the following commands into the Command reference
obj getdir X
camera camsetrelpos object
maybe this might help you
-
myke, I think the problem is in the maths. ;D
Trigonometry was too long ago for me to be any help, but I noticed this term
_xpos*sin(getdir plane)
However, it seems that
_xpos = 0
So that term will always be zero. Or am I missing something?
I would suggest that you temporarily take the trig out and make the script work with the camera, the aircraft and the GL target all in the same [vertical] plane. Once all is well, put the trig back in. Or maybe you've already done that.
And don't you need a
camcommitted _camera
inside the loop?
-
Sry... Nothing to yer prob... :P
But
And don't you need a
camcommitted _camera
inside the loop?
Why ???
When camCommit is 0 (zero, instant) there's no need for camCommitted... Actually there's no reason to use it all... I don't...
When using camCommitted the camera tends to stop before continuing to the next shot...
Of course that does not matter when using fixed shots but when doing drives or other kinda movements it can look quite crappy...
(I think this might be dependant on your amount of RAM and/or CPU ???)
-
I thought that was the command that actually made the camera move to the shot ... oh well, you learn something new every day.
-
Blanco your not far off, like Macguba said you need a constant (50) for the offset. It might be worth doing all the GetPos and GetDir stuff in a function, so you get an instant snapshot.
SetDirections.sqf:
private ["_plane","_pos","_frontx","_fronty","_backx","_backy","_planex","_planey","_planez","_currdir"];
_Plane=_This Select 0;
_CurrDir=GetDir _Plane;
_Pos=GetPos _Plane;
_PlaneX=_Pos Select 0;
_PlaneY=_Pos Select 1;
_PlaneZ=_Pos Select 2;
_FrontX=_PlaneX+Sin(_CurrDir)*50;
_FrontY=_PlaneY+Cos(_CurrDir)*50;
_CurrDir=_CurrDir-180;
_BackX=_PlaneX+Sin(_CurrDir)*50;
_BackY=_PlaneY+Cos(_CurrDir)*50;
[[_FrontX,_FrontY,_PlaneZ],[_BackX,_BackY,_PlaneZ]]
Then you can just do something like:
#loop
_Positions=[Plane] Call SetDirections
_camera camsetpos getpos (_Positions Select 1)
_camera camsettarget (_Positions Select 0)
@(True)
goto "loop"
The @ command should make sure it never tries to loop any quicker than it can handle.
This only works in 2D as you cant get the pitch of a plane, you could add to the cameras Z position to get an angled shot or work out the changes in altitude or something.
I have not tested the code but it should work, try it with a jeep and a couple of flagpoles to make sure.
-
thx, dude I'll give it a try, I've never used functions, tho
I've made that script to makes it possible to show cargo/driver postitions in moving vehicle.(no it's not switchcamera)
Actualy you can show any position. Like a closeup from a headlight while the vehicle is moving, or a roofcam, or whatever you want... :)
You can make your camscenes more dynamic with it.
I hope nobody made such a script before...
Script is done, demomission is done, but it needs a short tutorial, because it's a bit different from the normal camscript procedure.
Tutorial is written in Flemish (Dutch) , I only have to translate it in English.