chris330 0 Posted April 7, 2005 Dear All, I am making a camera script which will hopefully (eventually) make the camera attached to a game logic unit at the side of the helo pitch up and down with the helo. I have already taken care of making the game logic unit stay at the same position as the helicopter regardless of its heading. I just need to know how to get the pitch angle of the helo. I have tried to download schulle's function from ofpec but the link is bust. Anyone with any ideas as to how this can be done I would like to know as there is no way to do an inverse sine or cosine function in ofp Share this post Link to post Share on other sites
gandalf the white 0 Posted April 7, 2005 pitch angles cannot be "saved" or recorded in OFP afaik, if it was possible, the multiturret script would have been implemented already.. sorry... Share this post Link to post Share on other sites
chris330 0 Posted April 7, 2005 Thanks for the reply According to deschulle or whatever his name is his function made a global variable which called the pitch angle of an aircraft which was updated by a loop and callable throughout the mission if I remember correctly Share this post Link to post Share on other sites
chris330 0 Posted April 7, 2005 As just posted at OFPEC: I GOT IT TO WORK!!!!! Without the get pitch function. I have to say however I am using the difference in height between the pilot and helicopter because I don't have the get pitch function from deschulle yet. Hopefully that will be back online soon. If anyone's interested I will send them a demo mission via e-mail. Because of varying differences between heli position and pilot position some helicopters do not work well with this (the camera has a tendency to point up in the air). Works great with the Apache, AH1, and Mi-17 though. If I can get the getpitch function then I will be able to massively update this script to work with any helicopter. Also due to OFP limitations sometimes the heli bobs up and down on the screen quite jerkily. This is an OFP flaw as there is nothing wrong with the code Here's the code: [b said: Quote[/b] ]_camoffx = 5 _camoffy = -8 _helo = heli1 _pilot = pilot1 _cam1 = "camera" camcreate [0,0,0] _cam1 cameraeffect ["internal", "back"] _cam1 camsettarget cameraeffect1 _cam1 camsetrelpos [0,0,0] _cam1 camcommit 0 #start _cam1 camsettarget cameraeffect1 ;Get hypotenuse of distance from pilot to helicopter _x2 = getpos _pilot select 0 _x1 = getpos _helo select 0 _xdiff = _x2 - _x1 _y2 = getpos _pilot select 1 _y1 = getpos _helo select 1 _ydiff = _y2 - _y1 _l = sqrt((_xdiff^2) + (_ydiff^2)) ;Get height difference from pilot to helicopter _z2 = getpos _helo select 2 _z1 = getpos _pilot select 2 _zo = _z2 - _z1 ;Find hypotenuse to get sin and cosine of angle _h = sqrt((_l^2)+(_zo^2)) _sinangle = _zo/_h _cosangle = _l/_h ;evaluate where camsetrelpos command should set the camera to for _camoffy _e = (_sinangle) * (_camoffy) _a = (_cosangle) * (_camoffy) _heading = getdir _helo _angle = 360 - _heading _xa = (cos (_angle)) * _camoffx _ya = (sin (_angle)) * _camoffx ;Get position co-ordinates of helicopter _xh = getpos _helo select 0 _yh = getpos _helo select 1 _zh = getpos _helo select 2 ;Position the object cameraeffect1 setpos [(_xh + _xa),(_yh + _ya),_zh] cameraeffect1 setdir _heading _cam1 camsetrelpos [0,_a,-(_e)] _cam1 camcommit 0 ~0.0001 ?camend : exit goto "start" Â Share this post Link to post Share on other sites
chris330 0 Posted April 7, 2005 Correction!! I know why it jerks about. It is because of the difference between pilot and helicopter height values when they are over uneven terrain. This will be eliminated if I can get hold of the getpitch function . Share this post Link to post Share on other sites
gandalf the white 0 Posted April 7, 2005 is there a getpi.... ... ... somebody... enlighten me on this one... how come a multiturret tank can't be done with this? (yeah, I know that's a stubborn question...) Share this post Link to post Share on other sites
hardrock 1 Posted April 7, 2005 (chris330 @ April 07 2005,20:14) said: Correction!! I know why it jerks about. It is because of the difference between pilot and helicopter height values when they are over uneven terrain. This will be eliminated if I can get hold of the getpitch function . Take the absolute altitude from the pilot and the helicopter and you'll get correct values. Share this post Link to post Share on other sites
chris330 0 Posted April 7, 2005 Thanks for replying mate. I tried that by using a height above sea level script and it ran like garbage. I think it is a pretty useless script anyway as it jerks to hell when flying over raised areas of land like the mountains on Everon for example . Not really worth anybody's time but a good bit of experience building anyway. Nice to see my code working very well anyhoo EDIT: I should point out I am referring to my script as useless not the ASLHieght script Share this post Link to post Share on other sites
Guest [B.B.S.] T_D Posted April 7, 2005 The function of Dschulle works with the drop command. It creates 4 drops relative to the object and calculate bank and pitch from the positions of the drop. So you need a script where you create 4 drops and which activate another script (4 - for every drop one)where you have to save the position in a variable. Then you can calculate the bank and pitch. I hope you understand what i said and that the english isnt too bad. Share this post Link to post Share on other sites
UNN 0 Posted April 7, 2005 [b said: Quote[/b] ]is there a getpi.... There are two methods AFAIK, the getting the position of a dropped particles or getting the positions of dedicated game logic cargo positions. But for just the pitch of most aircraft, you dont need either. Just a pilot, an aircraft and a height above sea level function. With a bit of trig between the pilot and the heli. [b said: Quote[/b] ]how come a multiturret tank can't be done with this? Getting pitch and bank is easy enough. setting it is another thing all together. You could add multi turrets but they would be a type of simulated AI only, so I never botherd trying. Share this post Link to post Share on other sites
chris330 0 Posted April 8, 2005 ([b.B.S. said: T_D @ April 07 2005,22:24)]The function of Dschulle works with the drop command. It creates 4 drops relative to the object and calculate bank and pitch from the positions of the drop. So you need a script where you create 4 drops and which activate another script (4 - for every drop one)where you have to save the position in a variable. Then you can calculate the bank and pitch. I hope you understand what i said and that the english isnt too bad. Thanks for the reply. Could you elaborate a bit as I don't understand how to use drops The english was fine by the way Share this post Link to post Share on other sites
Guest [B.B.S.] T_D Posted April 8, 2005 I could download the function Share this post Link to post Share on other sites
chris330 0 Posted April 8, 2005 Cheers a bundle pal I'll have a go with it tonight and see if I can get the damn script to work smoothly. Please note it does work but is very jerky at the moment due to a number of factors Share this post Link to post Share on other sites
chris330 0 Posted April 8, 2005 IT REALLY WORKS  Using dshculle's pitch function means the camera is stable and does not jump around. The helicopter moves up and down a bit when going over uneven terrain but I'm sure this is an OFP limitation and nothing to do with the script as I've had it happen when not using the pitch function too  Anyone who is interested please get in touch and I will send you a demo mission. chris330330@hotmail.com  [b said: Quote[/b] ]_camoffx = 5 _camoffy = -8 _helo = heli1 _pilot = pilot1 _cam1 = "camera" camcreate [0,0,0] _cam1 cameraeffect ["internal", "back"] _cam1 camsettarget cameraeffect1 _cam1 camsetrelpos [0,0,0] _cam1 camcommit 0 #start _BankPitch = _helo call GetBankPitch _Pitch = _BankPitch select 1 _sinangle = sin(_Pitch) _cosangle = cos(_Pitch) ;evaluate where camsetrelpos command should set the camera to for _camoffy _e = (_sinangle) * (_camoffy) _a = (_cosangle) * (_camoffy) _heading = getdir _helo _angle = 360 - _heading _xa = (cos (_angle)) * _camoffx _ya = (sin (_angle)) * _camoffx ;Get position co-ordinates of helicopter _xh = getpos _helo select 0 _yh = getpos _helo select 1 _zh = getpos _helo select 2 ;Position the game logic cameraeffect1 setpos [(_xh + _xa),(_yh + _ya),_zh] cameraeffect1 setdir _heading _cam1 camsetrelpos [0,_a,_e] _cam1 camcommit 0 ~0.001 ?camend : exit goto "start" Share this post Link to post Share on other sites
chris330 0 Posted April 9, 2005 UPDATE**** I now have this script working perfectly, The helicopter no longer moves vertically on the screen even over uneven terrain. The reason it was moving was because of lateral changes in height above the ground between the helicopter and game logic unit the camera points at. But using a traingle and the distance command...I fixed it Helicopter now stays rock solid on the left or right of the screen and the camera changes angle to match it's pitch. Basically it's like having a a real camera screwed to the side of a helicopter Thanks very much for all the help I will now submit this to OFPEC's editing depot Share this post Link to post Share on other sites
chris330 0 Posted April 11, 2005 This script is now available in the Pending section of OFPEC's editing depot Share this post Link to post Share on other sites
HuNtA 0 Posted April 11, 2005 but, I must state now that this wouldnt work as a multi turret script unless either: A) you like crappy looking always upright MG's, turrets B) you make a complex and confusing anim system Share this post Link to post Share on other sites