Tutorial Advanced Cameras

Knights

You can change this now in User CP.
Reaction score
71
Advanced Cameras

So, if you havn't gotten into cameras much yet, lets start with the basics. A camera change is done with triggers. There are several preset things you can do.

Apply Camera Object(Timed) - Will apply a preplaced camera from the editor.

Pan Camera(Timed) - Will pan the camera to a preset region over time.

Pan Camera with Interpolated Height - Pans the camera to a place with a preset height.

Pan Camera as Nessecary - Pans the camera to a place ONLY IF NECESSARY, if you are already at the place, it will not try to pan there.

Set Camera Field(Timed) - Sets a camera field over time.

Rotate Camera around point - Will rotate the camera around a point for (Number)°.

Lock Camera to Unit - Locks the camera to a unit.

Lock Camera Orientation to unit - Locks the camera to a unit offset by something.

Play cinematic sequence - Will play a premade cinimatic sequence (Unnessicary)

Stop Camera - Stops the camera for a player no matter where it is going.

Reset Game Camera - Resets the camera entirely for a player.

Change Camera Smoothing Factor - Will make the camera very smooth and nice if set to a high number.

Reset camera smoothing factor - Sets the cameras smoothing factor to normal.

Sway camera source - Sways the camera source for a player with a velocity and magnitude.

Sway camera target - Sways the camera target for a player with a velocity and magnitude.

Shake Camera - Will shake the camera up and down for a player with magnitude.

Stop Shaking/swaying camera - Pretty clear itself...

Extend/shrink camera bounds - Will allow your camera to go farther around the map or less far around the map then before.

Set Camera Bounds - Locks the camera to a specific region, rendering you unable to move out of that region

Set Camera-Spacebar point - Sets the point where if you press spacebar it will take you there.


Triggering
So, now you get the basic preset commands.

Lets try to make a camera lock onto a random unit for every player.

Locking Camera
Code:
[B]Events[/B]
Time - Elapsed Game time is 0.00 seconds.
[B]Conditions[/B]
[I]None[/I]
[B]Actions[/B]
Player Group - Pick every player in (All players) and do (Actions)
          Loop - Actions
                   Camera - Lock camera target for (Picked Player) to (Random unit from (Units in(Playable Map Area))), offset by (0.00, 0.00) using Default Rotation.

So this will pick a random unit from the whole map and lock the camera for all players to it. Of course, every player will get a different unit to lock onto because a loop runs over for each picked player.

Third Person Camera
Now let's try to lock the camera onto a unit in a third person mode, and follow the unit when he turns.

Code:
[B]Events[/B]
Time - Every 0.01 seconds of game time
[B]Conditions[/B]
[I]None[/I]
[B]Actions[/B]
Custom Script : set bj_wantDestroyGroup = true
For Each Integer A from 1 to 12
          Loop - Actions
                   Set RandomUnit = (Random unit from (Units owned by (Player((Integer A))))
                   Set UnitAngle = (Facing of RandomUnit)
                   Camera - Apply Camera 002 for (Player(Integer A)) over 0.00 seconds.
                   Camera - Lock camera target for (Player(Integer A)) to RandomUnit, offset by (0.00, 0.00) using Default Rotation
                   Camera - Set (Player(Integer A)) camera Rotation to UnitAngle over 0.00 seconds.

This will lock the camera onto your unit as a third person camera. Of course this will only work if you only own one unit, and also if you set the camera 001 to be a neat third person type angle. I could set that camera any way I like to get different effects.




First Person Camera
This is quite like the Third Person one, but requires a different camera angle
and an offset.

Code:
][B]Events[/B]
Time - Every 0.01 seconds of game time
[B]Conditions[/B]
[I]None[/I]
[B]Actions[/B]
    For Each Integer A from 1 to 12
        Loop - Actions
            Set TempGroup = (Units Owned By (Player (Integer A)))
            Set RandomUnit = (Random unit from TempGroup)
            Custom Script: call DestroyGroup(udg_TempGroup)
            Set Pos = (Position of RandomUnit)
            Set PoRU = (Pos offset by (500) to (Facing angle of RandomUnit[Player(Integer A)) for (Player(Integer A))
            Custom Script: call RemoveLocation(udg_Pos)
            Set UnitAngle = (Facing of RandomUnit)
            Camera - Lock camera target for (Player(Integer A)) to RandomUnit, offset by (0.00, 0.00) using Default Rotation
            Camera - Set (Player(Integer A)) camera Rotation to UnitAngle over 0.00 seconds
            Camera - Pan camera to PoRU for (Player(Integer A)
            Custom Script: call RemoveLocation(udg_PoRU)
This will offset the camera to the unit plus 500 in the way its facing. That way you get the idea like you are in his head.





Cinematic Cameras
Let's try to make a cool cinimatic camera for the start of a game.
Code:
[B]Events[/B]
Time - Elapsed game time is 0.00 seconds
[B]Conditions[/B]
[I]None[/I]
[B]Actions[/B]
Cinimatic - Turn cinematic mode on for (All players)
Player Group - Pick every player in (All players) and do (Actions)
          Loop - Actions
                    Camera - Camera - Apply Camera 005 for (Picked player) over 0.00 seconds.
Cinematic - Send transmission to (All players) from Footman 001 <gen> named KnightsOfTables:  Play no sound and display Hi, I'm a knight of a table, and welcome to the Camera Tutorial.  I hope you enjoy your day.  Modify duration: set to 5 seconds and wait.
Cinematic - Send transmission to (All players) from Footman 001 <gen> named KnightsOfTables:  Play no sound and display ...I like pie...  Modify duration: set to 5 seconds and wait.
Player Group - Pick every player in (All players) and do (Actions)
          Loop - Actions
                   Camera - Reset game camera for (Picked player) over 0.00 seconds.
Cinimatic Turn cinematic mode off for (All players)
Just make sure your camera that you create has a good angle. Remember, to set a good camera angle, hold down the ctrl+right click and you can move the angle around. Shift+right click will change zoom.




Rotation
Now let's make it so if the player types escape it will rotate the camera around the point they are looking at.

Code:
[B]Events[/B]
Player - Player 1 (Red) skips a cinimatic sequence
*You will have to repeat this for each player allowed*
[B]Conditions[/B]
[I]None[/I]
[B]Actions[/B]
Camera - Rotate camera 360 degrees around (source of current camera view) for (Triggering player) over 5.00 seconds.
Wait 5 seconds
Camera - Reset the game camera for (Triggering player) over 0.00 seconds
So if you press escape, it will rotate the camera totally around 360 degrees (a full circle) around the point that you are looking at.




Smoothing
Smoothing the camera can be VERY useful for cinimatics, as you will see. What this does, is makes the camera run smoother, instead of stopping abruptly. I recommend to do this EVERY time you pan the camera.

Code:
[B]Events[/B]
Time - Elapsed game time is 0.00 seconds.
[B]Conditions[/B]
[I]None[/I]
[B]Actions[/B]
Camera - Change the camera smoothing factor to 10.00 over 0 seconds.
Cinematic - Turn cinematic mode on for (All players)
Pick every player in (All players) and do Camera - Pan camera for (Picked player) to (region 001) over 20.00 seconds.
Wait 20.00 seconds.
Cinematic - Turn cinematic mode off for (All players)
Camera - Reset the camera smoothing factor.
That changes the camera smoothness for 20 seconds, turns on cinimatic mode, and pans the camera to region 001.

Camera Bound Changing
Changing the Camera Bounds can be very useful for minigames. This will make the camera unable to travel outside of the camera bounds, and therefore unable to see what is going on around them. Very good for all minigame maps - Like Uther Party - or even games with minigames in them.

Code:
[B]Events[/B]
Time - Elapsed game time is 0.00 seconds.
[B]Conditions[/B]
[I]None[/I]
[B]Actions[/B]
Player Group - Pick every player in (All players) and do (Camera - Set the camera bounds for (Picked player) to Region 001
Wait 20.00 seconds.
Player Group - Pick every player in (All players) and do (Camera - Set the camera bounds for (Picked player) to Region 002
Wait 20.00 seconds.
Player Group - Pick every player in (All players) and do (Camera - Set the camera bounds for (Picked player) to Region 003
Wait 20.00 seconds.
Player Group - Pick every player in (All players) and do (Camera - Set the camera bounds for (Picked player) to Region 004
Wait 20.00 seconds.
So, this coding will set the camera so it is unable to move ouside of Region 001 for 20 seconds, then Region 002 for 20 seconds, etc. As I said before, very useful for minigames, though I am sure there are many other good uses.


Panning the Camera Nicely
Panning the camera can be an annoying thing. You want to make it nice, but you don't want to keep the people waiting. Another problem with them is the players can still move the camera while it is panning, and we don't want this. So let's make it so they can't!

Code:
[B]Events[/B]
Time - Elapsed game time is 0.00 seconds.
[B]Conditions[/B]
[I]None[/I]
[B]Actions[/B]
Cinematic - Turn cinematic mode on for (All players)
Pick every player in (All players) and do (Camera - Pan camera for (Picked player) to (Center of (Region 005)) over 0.00 seconds)//This is to start the camera at region 005.
Camera - Change the smoothing factor to 15
Pick every player in (All players) and do (Camera - Pan camera for (Picked player) to (Center of (Region 006)) over 5.00 seconds)
Wait 5.00 seconds
Pick every player in (All players) and do (Camera - Pan camera for (Picked player) to (Center of (Region 007)) over 5.00 seconds)
Wait 5.00 seconds.
Pick every player in (All players) and do (Camera - Rotate camera -90 degrees around (Center of (Region 007)) For (Picked player) over 5.00 Seconds)
Wait 5.00 seconds.
Pick every player in (All players) and do (Camera - Pan camera for (Picked player) to (Center of (Region 008)) over 5.00 seconds)
Wait 5.00 seconds.
Pick every player in (All players) and do (Camera - Pan camera for (Picked player) to (Center of (Region 009)) over 5.00 seconds)
Wait 5.00 seconds.
Pick every player in (All players) and do (Camera - Pan camera for (Picked player) to (Center of (Region 010)) over 5.00 seconds)
Wait 5.00 seconds.
Pick every player in (All players) and do (Camera - Rotate camera 180 degrees around (Center of (Region 010)) For (Picked player) over 5.00 Seconds)
Wait 5.00 seconds.
Camera - Reset the camera smoothing Factor
Pick every player in (All players) and do (Camera - Reset the game camera for (Picked player) over 0.00 seconds)
Cinematic - Turn cinematic mode Off for (All players)
This will make the camera turn on cinimatic mode, then center of the starting point. It will then pan around the map, while rotating to change directions. If you wished this to work for your map, to get a veiw of the world, you would have to adjust the rotation points and degrees.


This is all I have for you today, please post comments below...:D

I hope it helped, and if any questions please feel free to PM me with them.
 

Attachments

  • Camera Tutorial Map.w3x
    17.9 KB · Views: 686

wonderpriest

New Member
Reaction score
18
Hmm. I don't use cameras much, but I guess this could help cinematic makers. Nice, but you should probably fix the leaks if you are using Periodics.
 

C-Death

I love you
Reaction score
45
Nice, +rep
 

Knights

You can change this now in User CP.
Reaction score
71
Thanks I had no clue how to spell that, I guess I shoulda checked WE...Ah well...

BuMp? I think I'm allowed to bump it...hopefully I am.
 

ragingspeedhorn

Is a Banned Asshole
Reaction score
94
Nice tutorial, but 1 thing though, please change the text in the beginning that is blue, it is annoying to look at :p
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
>>
Code:
Player Group - Pick every player in (All players) and do (Actions)
          Loop - Actions
                   Cinimatic - Turn cinimatic mode on for (All players)
                   Camera - Camera - Apply Camera 005 for (Picked player) over 0.00 seconds.
                   Cinimatic - Send transmission to (All players) from Footman 001 <gen> named KnightsOfTables:  Play no sound and display Hi, I'm a knight of a table, and welcome to the Camera Tutorial.  I hope you enjoy your day.  Modify duration: set to 5 seconds and wait.
                   Cinimatic - Send transmission to (All players) from Footman 001 <gen> named KnightsOfTables:  Play no sound and display ...I like pie...  Modify duration: set to 5 seconds and wait.
                   Camera - Reset game camera for (Picked player) over 0.00 seconds
                   Cinimatic Turn cinimatic mode off for (all players)

This is a poorly made trigger... for each player, it will turn the cinematic on for ALL the players, (not good) for each player it will apply the camera (good), for each player, it will send a transmission to All Players (not good), etc. You will hae to put both the reset camera, and the camera pan inside their own SEPERATE pick every player loop.
 

Chocobo

White-Flower
Reaction score
409
Code:
]Events
Time - Every 0.01 seconds of game time
Conditions
None
Actions
Player Group - Pick every player in (All players) and do (Actions)
          Loop - Actions
                   Set UnitAngle[((Player Number of (Picked player))] = [B](Facing of (Random unit from (Units owned by (Picked player)))[/B] //Can not handle 2 times the same random unit. There still a little chance ^^
                   [B]Camera - Apply Camera 002 for (Picked player) over 0.00 seconds.[/B] [I]//No need if it applies an another point. Better to use Camera - Set Far Z..., Set Angle of Attack..[/I]
                   Camera - Lock camera target for (Picked player) to [B](Random unit from (Units owned by (Picked Player)))[/B], offset by (0.00, 0.00) using Default Rotation //The Super Leak!
                   Camera - Set (Picked players) camera Rotation to UnitAngle[((Player Number of (Picked player))] over 0.00 seconds.

It has a lot of leaks because the group generated 16 times (Take a example, you have 100 units, it will take a random of them, generates 200 bytes/0.01s, Virtual Memory will grow by 20000 bytes ~ 20 kb/1s, multiply it by 16 and you get a fantastic number of .. I let you calculate)

Code:
]Events
Time - Every 0.01 seconds of game time
Conditions
None
Actions
Custom Script : set bj_wantDestroyGroup = true
For Each Integer A from 1 to 12
          Loop - Actions
                   Set RandomUnit = (Random unit from (Units owned by (Player((Integer A))))
                   Set UnitAngle = (Facing of RandomUnit)
                   Camera - Apply Camera 002 for (Player(Integer A)) over 0.00 seconds.
                   Camera - Lock camera target for (Player(Integer A)) to RandomUnit, offset by (0.00, 0.00) using Default Rotation
                   Camera - Set (Player(Integer A)) camera Rotation to UnitAngle over 0.00 seconds.
 
G

G1thy4nk1

Guest
you are excellent!

ive been waiting for this time to come of an idea for the first person camera (i already have a third person camera) this should make my RPG more realistic thanks! youre a genius! ;) :cool: :shades:
 

Knights

You can change this now in User CP.
Reaction score
71
@chocobo: Thanks I'm going to fix that, (I hate leaks and suck at em) :mad: but I know they are a pain, so yes I am going to fix it.(I used your code, I figured it would be faster, sorry :( ...:D)

@G1thy4nk1: Thanks a lot...but I don't recommend using that one yet, (wait till I fix)(Okay I fixed you can use now :D)


Thanks,
KnightsOfTables
 

martix

There is no spoon
Reaction score
49
This is a 5 star tut, I wonder when its gonna go in the tut repository.
 

Knights

You can change this now in User CP.
Reaction score
71
*Bump* Comments please...also rate post as always -- I need comments for improvements...if no more comments equal true, improvments equal false.


Thinking of Triggers,
KnightsOfTables
 

Knights

You can change this now in User CP.
Reaction score
71
Extraz

I added:

-Camera Smoothing
-Camera Bound Changing
-Camera Panning in a Nice Way
-Fixed Tutorial Map


Will add more here as I add more on the tutorial, be sure to check it out constantly...
 

Chewbalka

New Member
Reaction score
14
Code:
Time - Every 0.01 seconds of game time
Conditions
None
Actions
Custom Script : set bj_wantDestroyGroup = true
For Each Integer A from 1 to 12
          Loop - Actions
                   Set RandomUnit = (Random unit from (Units owned by (Player((Integer A))))
                   Set UnitAngle = (Facing of RandomUnit)
                   Camera - Apply Camera 002 for (Player(Integer A)) over 0.00 seconds.
                   Camera - Lock camera target for (Player(Integer A)) to RandomUnit, offset by (0.00, 0.00) using Default Rotation
                   Camera - Set (Player(Integer A)) camera Rotation to UnitAngle over 0.00 seconds.

Set RandomUnit = (Random unit from (Units owned by (Player((Integer A))))
2 questions
is this and what kind of varaible is this?

And i cant find the
(Random unit from (Units owned by (Player((Integer A))))
in list, your preview thing has nothing on this part o_O
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top