Home   Help Search Login Register  

Author Topic: SOLVED: Rotate Camera After a Button Press  (Read 1079 times)

0 Members and 1 Guest are viewing this topic.

Offline SniperUK

  • Members
  • *
  • I'm a llama!
SOLVED: Rotate Camera After a Button Press
« on: 23 Jul 2007, 01:22:56 »
Hi again guys, this should be a fairly simple query but i keep overlooking my mistake and can not for the life of me find it in my own code.
What i am trying to do is rotate an existing camera. I have included the script as shown below but will breifly explain what the script does:

1) The script initiates, builds the camera and as you can see by the code drops straight down from 300 to 100 ft when looking at the ground.
2) The script gets stuck in a loop and the camera sits there awaiting input.
3) At the same time a dialog is waiting on the screen, which gives the user the option to press rotate which should feed a public variable into the script which activates the options contained within the loop.
4) I have tried changing the xaxis in the camSetRelPos statement within the loop however the camera just rotates once and will not continue.
5) My next step was to try initiating a variable such as rotatecoord = 0 at the start of the script, and then using a rotatecoord = rotatecoord +1 in the loop. However the camera still seems to rotate only the once and no matter whether i set the xaxis to 1 or 10 still only rotates to the same angle.


Camerascript.sqs

_camera = "camera" camcreate [_pos select 0,_pos select 1,_pos select 2]
_camera cameraeffect ["Internal","back"]

_camera camsettarget _pos
_camera camsetrelpos [0,-1,300]
_camera camcommit 0
@camCommitted _camera
~1
_camera camsettarget _pos
_camera camsetrelpos [0,-1,200]
_camera camcommit 0
@camCommitted _camera
~1
_camera camsettarget _pos
_camera camsetrelpos [0,-1,100]
_camera camcommit 0
@camCommitted _camera

#cameraloop

? (rotate == 1) : _camera camsettarget [(getpos _camera select 0), (getpos _camera select 1)];
? (rotate == 1) : _camera camSetRelPos [0, -1, (getpos _camera select 2)]
? (rotate == 1) : _camera camcommit 0
? (rotate == 1) : rotate= 0;

? (endcam == 0) : goto "cameraloop"

Any ideas? As this one has got me stumped for the time being till i find my own mistake. Thanks in advance.
« Last Edit: 23 Jul 2007, 09:07:02 by SniperUK »

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Rotate Camera After a Button Press
« Reply #1 on: 23 Jul 2007, 01:54:01 »
Dont use relative positions of positions, use relative positions of "things". Try changing your _camera camsettarget _pos by _camera camsettarget _logic (put a created gamelogic in the desired _pos before). Then just use _logic setDir _desireddirection and commit the camera again without changing the relative pos. The camera will rotate with the logic.

Offline SniperUK

  • Members
  • *
  • I'm a llama!
Re: Rotate Camera After a Button Press
« Reply #2 on: 23 Jul 2007, 02:47:19 »
made perfect sense, i created a logic at the desired location and called it cameralogic and i changed the code to reflect this, even though i am changing the direction of the logic to 49 and telling it to target the logic. It still didnt change the rotation of the camera, do you know what i am doing wrong?

? (rotate == 1) : cameralogic SetDir 49;
? (rotate == 1) : _camera camsettarget [(getpos cameralogic select 0), (getpos cameralogic select 1)];
? (rotate == 1) : _camera camSetRelPos [0, -1, (getpos _camera select 2)];
? (rotate == 1) : _camera camcommit 0
? (rotate == 1) : rotate= 0;

PS. I did try just ? (rotate == 1) : _camera camsettarget cameralogic;
This did work to an extend but it causes some pretty funny results where the camera when moved left or right in some areas would just invent itself 180 degrees without warning.

Fixed issue by setting the dir of the gamelogic everytime the camera was moved:
rotatedcam = rotatedcam + 10;
? (rotate == 1) : cameralogic SetDir rotatedcam;
? (rotate == 1) : _camera camsettarget gamelogic;
? (rotate == 1) : _camera camSetRelPos [0, -1, (getpos _camera select 2)];
? (rotate == 1) : _camera camcommit 0
? (rotate == 1) : rotate= 0;
« Last Edit: 23 Jul 2007, 09:06:43 by SniperUK »