OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: armymanbronson on 29 Aug 2002, 16:46:45

Title: Camera stick to the pilot
Post by: armymanbronson on 29 Aug 2002, 16:46:45
hey guys im doing a jet mission now i have an empty jet with a pilot in it with this moveindriver jet in his init field, i want the camera to stick with the pilot. like i know how to do basic cut scenes just want to know the command for making the camera stay with the target thats all.
cheers.
bronson
Title: Re:Camera stick to the pilot
Post by: crow on 29 Aug 2002, 17:53:44
 :)Name the pilot aP then place this line in your script;
_cam camsettarget aP
That should do it for you.  aP can be any name you want. :)
Title: Re:Camera stick to the pilot
Post by: Backoff on 29 Aug 2002, 19:51:10
Hi,

Not sure i understood it right, seems you want to make the camera following the pilot, right?
Personnaly, I'm using a loop for this effect. Here the code:

_cam camSetTarget MyPilot
#loop1
   _cam camSetRelPos [-5,0,0]
   _cam camCommit 0
   @camCommitted _cam
   ~0.01
goto "loop1"

This will make the camera follow its target. In this exemple the cam will be 5 meters on the left of the pilot ([-5,0,0]). You may need to end this loop sometimes, so you can add a counter and an exit condition.

Hope this helps.


Title: Re:Camera stick to the pilot
Post by: tai mai shu on 30 Aug 2002, 05:30:15
how do you add a counter?  something on teh lines of
_counter = 0
#loop
? (_counter == 5) : exit
_counter = _counter + 1
~1 goto loop

is that how you make a counter?
Title: Re:Camera stick to the pilot
Post by: Backoff on 30 Aug 2002, 11:27:20
yeah, something like that... but for a time counter, it should be incremented with the same value as the delay value.

_i = 0
#loop1
   ...
   ~0.01
   _i = _i + 0.01
?(_i < 5) goto "loop1"

this should make the camera following its target for 5 seconds.

The cool thing with this loop is that you can create awesome effects. IE: a camera is following a plane and make a 360° tourn around on the same time:

_cam camSetTarget MyPilot
_i = 0
#loop1
  _cam camSetRelPos [cos((getdir MyPilot) + _i) * 10,sin((getdir MyPilot) + _i) * 10,0]
  _cam camCommit 0
  @camCommitted _cam
  ~0.01
  _i = _i + 1
(?_i < 360):goto "loop1"

in this case, the exit condition is met when the camera did a 360° turn around.
Title: Re:Camera stick to the pilot
Post by: KTottE on 30 Aug 2002, 11:41:05
Even if this is more towards Script Ideas I'll post it here.

The 360° thing is not that advanced. Fairly simple, right?
Also makes for a fairly simple shot.
But, what if you add a third dimension to the 360° spin?
Like, go below/above the plane in the same pan?
A = Start
B = Mid point
C = End
D = Airplane

                 B

                 ^
                 |
A           <- D ->            C

Did that make sense?

The camera starts on the right side, moves to the front and up so at B it's looking down at the cockpit from the front, then moves down to end up at C which is a point on the left side.
That shouldn't be impossible, right?
It's just that it's early right now, and I'm not that up to speed on my maths.
Title: Re:Camera stick to the pilot
Post by: Backoff on 30 Aug 2002, 11:52:54
yeah, that's piece of cake, indeed.

For this effect, you need a 180° effect and a height threshold. Basically you increment z axis with say a value of 0.1 until the camera reach 90° and then decrement it with the same value:

_cam camSetTarget MyPilot
_i = 0
_z = 0
#loop1
  ?(_i < 90):_z = _z + 0.1
  ?(_i > 90): _z = _z - 0.1
  _cam camSetRelPos [cos((getdir MyPilot) + _i) * 10,sin((getdir MyPilot) + _i) * 10,_z]
  _cam camCommit 0
  @camCommitted _cam
  ~0.01
  _i = _i + 1
(?_i < 180):goto "loop1"
Title: Re:Camera stick to the pilot
Post by: KTottE on 30 Aug 2002, 12:02:17
Thanks mate =)
I was thinking about the same thing, but my sleep deprived brain could not muster the energy to do the very simple math for that one ;D
Title: Re:Camera stick to the pilot
Post by: Backoff on 30 Aug 2002, 12:44:21
np, brains need to warm up too  :)

btw, there was a little logic error in my last script, it is edited and fixed.

oh, and you may have to tweak the time delay and the distance increments to have a smooth effect, i can't test it right now, but the main system does work.