Camera scripting tutorial
By Rob.
This is a simple camera scripting tutorial that should give u the experience of learning this in less than an hour.
Thx to Snyper that helped me learn camera scripting in the first place, now I'm here to pass on the knowledge.
First off though I would like to say that camera scripting is an advanced language to some stages and doesn't always work the way u want it to. When you become well aware of using scripts, try to fill out the programming detail as much as pos.
Alright lets get started.
First create a new txt document in your mission folder, being "operation flashpoint/ users/ yourname/ missions.
now rename the document camera.sqs, it doesn't have to be camera but it's easier to remember.
When prompted say yes. If the file turns out to be a single file double click it and scroll down the large menu until you get to notepad. Open it with that and now you shall be able to edit and write in it at any time.
Now to the writing stage.
In nearly every cutscene, intro or outro people add the command line
titlecut [" ", "black in", 2]
What this does is creates a black in effect for 2 seconds to give the scene a good effect. If you are wanting to use this at the beginning of the script then I suggest that would be the first thing you write because without this at the beginning the script normally takes a little time to create the camera , so you get a little glimpse of a unit at the beginning. The first two quote marks are used to add text if u wanted to say something, like "well done", this would come up in the middle of the screen while it is blacking in.
If anyone wants this effect I seriously recommend that it is used straight away in the script otherwise u will see units and it ruins the atmosphere..
You can use black in, black out white in or white out for the effects.
NOTE: Black out and White out sometimes neva finish, so you will get a constant black or white screen, so use these at the end of the scenes. Unless you command it to black or white in again and it shall remove the effect.
But here is where we start to create our camera. The next thing to tell the game to create us a camera.
So add,
_cam = "camera" camcreate [0,0,0]
_cam is always used to give the camera an order. If you do not specify this it will not recognise what you are trying to say.
The "camera" tells the game that you are wanting to give the camera an order: The first is to create a camera, camcreate means a new camera to be created.
The areas where [0,0,0] is used, is to specify what angle you want the camera to start as, but that is going onto the very advanced stages you can make amazing effects without it. I personally never use it.
alright lets get this camera rollin!
_cam cameraeffect ["internal", "back"]
This is used in every script. It simply tells the game that the camera is going to be internal and behind whatever the targets going to be, but you can use: -
TOP |
LEFT |
RIGHT |
FRONT |
BACK |
LEFT FRONT |
RIGHT FRONT |
LEFT BACK |
RIGHT BACK |
LEFT TOP |
RIGHT TOP |
FRONT TOP |
BACK TOP |
BOTTOM |
besides from just back.
When making cutscenes its a good idea to disable the radio so that the team leader doesn't interfere with the scene.
so by adding the line EnableRadio false stops anyone from using radio commands while in the scene. To deactivate it just change the false to true.
ok.... now we are going to tell the camera wot to do.
first off we have to start off by telling the camera what target to target.
so add the lines _cam camsettarget unitname
This commands the camera to lock on to a specific unit or object depending on what you have called it. Unitname is the name of the unit or object.
Ok next we have to tell the camera where to position itself :
_cam camsetrelpos [X,Y,Z]
This tells the camera to move X number of meters across. Y number of meters forwards or backwards and Z is the meters above the object.
e.g. If I wanted the camera to target "aP" and move the camera 3 meters to the right of him, 8 meters in front and 1.7 meters up.
_cam camsettarget aP
_cam camsetrelpos [3, 8, 1.7]
If I wanted to go left or behind the object I would simply add a - , this would minus the No. of meters.
The setrelpos is where most of the good effects com in.
The next step is to tell the camera how long it should take to move on to the object.
_cam camcommit 0
Setting the commit to 0 would make the camera immediately move the target if asked.
Its important that you keep the number to 0 when specifying the first target because that camera has a good reputation to start out to sea then fly in.
So try to use it with the next target that is to be targeted.
Ss an example, if I had two men, one called aP and the other called man, and I wanted to first make the camera target aP then move onto man, I would use
_cam camcommit 0 for aP and when I set the camera to target man, taking the camera 4 seconds to fly across to him I would use
_cam camcommit 4.
Easier way for you to understand.
titlecut ["this is a test", black in", 2]
_cam = "camera" cameracreate [0,0,0]
_cam cameraeffect ["internal", "back"]
_cam camsettarget aP
_cam camsetrelpos [ 0, 1, 1.7]
_cam camcommit 0
@camcommitted _cam
~4
_cam camsettarget man
_cam camsetrelpos [ 0, 1, 1.7]
_cam camcommit 4
@camcommitted _cam
What this will do is to make the camera display a black screen and add the words "this is a test", next it will target aP and position itself right in front of his face. @camcommitted _cam is the next part. You MUST always add this line after _cam commit because it confirms that the camera is committed to the unit.
~ is a timer of how long to count for before moving on with the script. In my case it has to wait 4 seconds before targeting man.
Because I have specified that the _cam commit is 4 for man, after ~4 seconds of waiting the camera it will take an additional 4 secs to target and move to the position set in the setrelpos for that unit. Confused? hope not yet. this is easy once you get the hang of it. its just a matter of listening to me blabbering on while you learn.
Anyway moving on!!!!
You have now covered the very basics of camera scripting. Give yourself a pat on the back (that's unless u don't understand)
Right, now to finish off the script.
In order for you to be able to carry on playing after you have finished the script you want to take control again so add
_cam cameraeffect ["terminate", "back"]
Every time you have made a camera script u have to destroy the camera otherwise it will just stay there and you wont be able to play.
camdestroy _cam
This goes after the terminate back command.
Then to give it a nice effect use the black out command as we have gone over at the beginning.
titlecut [" ","BLACK OUT",2]
Then if you disabled the radio its a good idea to re-enable it again.
enableRadio true
Then
to command the script to exit u simply add exit.
exit
PPPHHHEEWWW!!!!
now you should be intelligent enough to camera script.
There is a very basic example mission with a script for you to use. Get it here