Jump to content
Sign in to follow this  
undercoverbrother

Can't get SwitchCamera command to work (using sqf script file)

Recommended Posts

Hey everyone,

First of all excuse me, I know I've posted a lot of questions on this topic lately, but I'm actually working on something big here (or at least big for my standards) - my very first cutscene, for my very first (serious) mission. From searching through thread after thread it isn't very hard to see how many questions there are on work with "camera.sqs" and hopefully this will be my last question on this topic for a while, so bear with me:)

First up here is what I've got saved into a SQF file called "Scene1.sqf". I've shortened and simplified it:


titlecut [" ","BLACK IN", 5]

;=== 14:21:08
_camera = "camera" camcreate [0,0,0]
_camera cameraeffect ["internal", "back"]
_camera camPrepareTarget [3595.11,103650.81,-148.97]
_camera camPreparePos [3402.12,3487.40,5.20]
_camera camPrepareFOV 0.700
_camera camCommitPrepared 0
@camCommitted _camera

;=== 15:52:01
_camera camPrepareTarget [-51530.92,-75321.34,-10783.29]
_camera camPreparePos [5593.83,5614.31,3022.15]
_camera camPrepareFOV 0.700
_camera camCommitPrepared 8
@camCommitted _camera

Player cameraEffect ["terminate", "back"]
camDestroy _camera
titlecut [" ","BLACK IN", 2]
Exit;

Everything works fine as far as cycling through each shot goes. My problem is at some point I want the camera to switch to an AI soldier, looking through his eyes and after this is done, allow the player some time before switching back to cycling through the pictures I have taken with "camera.sqs". I have tried using this:


titlecut [" ","BLACK IN", 5]

;=== 14:21:08
_camera = "camera" camcreate [0,0,0]
_camera cameraeffect ["internal", "back"]
_camera camPrepareTarget [3595.11,103650.81,-148.97]
_camera camPreparePos [3402.12,3487.40,5.20]
_camera camPrepareFOV 0.700
_camera camCommitPrepared 0
@camCommitted _camera

_unit switchCamera "INTERNAL";
~60

;=== 15:52:01
_camera camPrepareTarget [-51530.92,-75321.34,-10783.29]
_camera camPreparePos [5593.83,5614.31,3022.15]
_camera camPrepareFOV 0.700
_camera camCommitPrepared 8
@camCommitted _camera

~10

Player cameraEffect ["terminate", "back"]
camDestroy _camera
titlecut [" ","BLACK IN", 2]
Exit;

I have no idea how to use this command when using a SQF file, I mean I can just chuck it into the init line of the AI soldier and it works. I tried using this as well which I saw in a post by "Big Dawg Ks" (sorry if I got the name wrong)


_camera camSetTarget _unit;
vehicle _unit switchCamera "INTERNAL";
_unit cameraEffect ["terminate","back"];
titlecut [" ","WHITE IN in",3];
camDestroy _camera;

and puting that inbetween shots but it not work either. I'm at a complete loss as to what to do here, spent a lot of time researching and working on this. Any help is much appreciated.

Thanks

Edited by undercoverbrother

Share this post


Link to post
Share on other sites

I'm just guessing based a similar problem yesterday, but try adding a camDestroy _camera line right before that block of code in the last spoiler. It might reset the camera, other than that don't know.

Share this post


Link to post
Share on other sites

Apologise for replying late,

@ AZcoder. I didn't work what I'm still getting taken back to a completely static screen showing some hills and grass:confused:

Out of desperation I have just dumped most of my script into another folder, heres what I've left in "Scene.sqf" to see if I can get the "switchCamera" command to work:


titlecut [" ","BLACK IN", 5]

;=== 14:21:08
_camera = "camera" camcreate [0,0,0]
_camera cameraeffect ["internal", "back"]
_camera camPrepareTarget [3595.11,103650.81,-148.97]
_camera camPreparePos [3402.12,3487.40,5.20]
_camera camPrepareFOV 0.700
_camera camCommitPrepared 0
@camCommitted _camera

camDestroy _camera
_camera camSetTarget _unit
vehicle _unit switchCamera "INTERNAL"
_unit cameraEffect ["terminate","back"]
titlecut [" ","WHITE IN in",3]
camDestroy _camera;

I added that part before that last block of code. Still no luck, thanks anyway. Check out this thread out: http://forums.bistudio.com/showthread.php?t=107535&highlight=_camera+camSetTarget+_unit%3B+vehicle+_unit+switchCamera+INTERNAL%3B+cameraEffect+titlecut+ Thats were I got that block of code in the last spoiler from. It seemed to work for that guy, would this have something to do with saving the script in a SQF file.

A few more pieces of information which I think is important, the AI soldier called "_unit" is in a vehicle. I've tried using the switchCamera command and it worked when the AI soldier was on the ground, but not when he was in a vehicle. Also would it be possible to instead of switch cameras just use this http://community.bistudio.com/wiki/selectPlayer and switch AI soldiers to player controlled for a short time and if so can anyone provide the syntax for it.

Edited by undercoverbrother

Share this post


Link to post
Share on other sites

Your solution worked!!! Only issue is that you cannot switch to a unit who is currently in a vehicle (don't know a way around this). Instead I used this:

selectNoPlayer
selectPlayer _player

To switch between players. This is great, as with the switchCamera command you did have free look, instead you were only allowed to see what the AI sees (don't get me wrong, I think that makes sense). Here you actually control the player, allowing you to have free look and access a unit in a vehicle. Thanks for you help anyway,

Edited by undercoverbrother

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  

×