• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

Creating an Keyboard-Controlled-Camera

Level 6
Joined
Apr 24, 2008
Messages
174

How to create an Keyboard Controlled Camera

Use your Keyboard arrows to change the camera

Made by MyHummeR (2009/05/25)
Copyright

Click here to fast-download an Demo Map for this system (soon available).

Welcome! In this tutorial, I will teach you how to make an cool controllable camera in Warcraft, in the GUI (Trigger) language. If you follow this guide to 100%, I ensure you that you will have a cool camera that works MUI (Multiplayer) and is leakless and free from bugs!

You will be able to pan your cameras angle and rotation smoothly around a unit, using your UP, DOWN, LEFT and RIGHT keyboard arrows!
Before we are done with this Guide, we should have done:

  • Creating the first Trigger
  • Setting the Variables and the base Actions
  • Creating the first controllable Camera
  • Copying and making it MUI
  • Complete!
So, lets get started!

Part One - Creating the first Trigger

Open your Trigger Editor (Hotkey: F4) and create a new trigger called "Camera Start". This trigger is made to set the Variables that we will need for this system.


Part Two - Setting the Variables and the base Actions

Ok, in the Trigger we made (Camera Start), create this action:

  • Camera Start
    • Events
      • Time - Elapsed game time is 0.02 seconds
The time can be 0.01 too, it does not really matter. You can also use the Map initialization event. Ok, so what this will do is that the trigger will start after 0.02 seconds in Game Time. When the trigger starts, we want it to do some actions for us. So, create this action:
  • Camera Start
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
We will use this for setting some Variables soon. The "... from 1 to 12..." is the 1-12 Player numbers. This is required if we want the spell to work for more than one players. Ok, once done, you will need to make a new Variable. So, open your Variables (Hotkey: CTRL+B (in the Trigger Editor)). Make a new Variable and call it "Player_Character" and type "Unit" and check the "Array" box. This will set the unit that the camera should work on. Ok, so now we should Set the variable. Should look like this:

  • Camera Start
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Set Player_Character[(Integer A)] = (Random unit from (Units owned by (Player((Integer A))) matching (((Matching unit) is A Hero) Equal to True)))


Notice: You can set the variable to any unit you want, this was just an example. This set will work on a Hero unit only. So, set it to any unit you would like.

The "Player_Character[(Integer A)]" is required or else it wont work in MUI. The Integer A function will add the number 1 to 12 (Player 1 Red - Player 12 Brown). So, now you know what the Integer A does, right? :thumbs_up:

Ok, time for some more Variable sets. Now, create a new Variable named "Camera_Angle" of type "Real", also check "Array" on this variable. This Variable will work as our Camera Angle (the angle of how the camera should be viewed). Just like the Player_Character Variable, we will set this Variables Array to Integer A, and the Angle here should be 320.00 or kind of whatever you want, but let's do 320 now. So, set the Variable to that, the trigger should now look something like this:

  • Camera Start
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Set Player_Character[(Integer A)] = (Random unit from (Units owned by (Player((Integer A))) matching (((Matching unit) is A Hero) Equal to True)))
          • Set Camera_Angle[(Integer A)] = 320.00
So, now we have set the Unit and the Angle, still alot to do.
Next, we will set the Camera Distance! So, make a new Variable of type "Real", named "Camera_Distance", and like the other Variables, the "Array" box should be checked. Set it to 1300.00, that should make a good Distance. Oh right, I shoudl explain what this does :xxd:
Well, this Variable will work as our Camera Distance, it's the distance the camera will have to the unit. The higher number you have, the longer the distance will become.
Well, your trigger should now look like this:

  • Camera Start
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Set Player_Character[(Integer A)] = (Random unit from (Units owned by (Player((Integer A))) matching (((Matching unit) is A Hero) Equal to True)))
          • Set Camera_Angle[(Integer A)] = 320.00
          • Set Camera_Distance[(Integer A)] = 1300.00
So, we got unit, angle and distance. But, we are still missing the camera Rotation. The Rotation is how the camera should move around the unit.
This Variable is not set by Numbers, but by the Facing Angle of your unit.
Well, make an variable named "Camera_Rotation" of type "Real".
Set the Variable to work for as Unit Rotation, should look like this:

  • Camera Start
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Set Player_Character[(Integer A)] = (Random unit from (Units owned by (Player((Integer A))) matching (((Matching unit) is A Hero) Equal to True)))
          • Set Camera_Angle[(Integer A)] = 320.00
          • Set Camera_Distance[(Integer A)] = 1300.00
          • -------- You are here now: --------
          • Set Camera_Rotation[(Integer A)] = (Facing of Player_Character[(Integer A)])
What we did here, is that we set the Variable to the Facing of the Player_Character (the first Variable we made). Ok, moving on!
Next, we will need to create some new triggers, but first, make sure this is how your trigger looks like now:

  • Camera Start
    • Events
      • Time - Elapsed game time is 0.01 seconds
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Set Player_Character[(Integer A)] = (Random unit from (Units owned by (Player((Integer A))) matching (((Matching unit) is A Hero) Equal to True)))
          • Set Camera_Angle[(Integer A)] = 320.00
          • Set Camera_Distance[(Integer A)] = 1300.00
          • Set Camera_Rotation[(Integer A)] = (Facing of Player_Character[(Integer A)])

Part three - Creating the first controllable camera

Time to make the first (Singleplayer) camera! Don't worry, we will make this work MUI :thumbs_up: Let's make a new trigger and call it "Camera Work". This trigger will be used for setting the camera every 0.01 seconds (this is needed to disable the mouse-scroll). So, make a new event in the trigger, like this:

  • Camera Work
    • Events
      • Time - Every 0.01 seconds of game time
That will do so every 0.01 seconds in the game, the trigger will launch and do our wanted actions. Now, to make this as clean as possible, we will add an Player Group that checks so only Online Players cameras will move. So, make a new action the the "Camera Work" trigger like this:

  • Camera Work
    • Actions
      • Player Group - Pick every player in (All players matching (((Matching player) slot status) Equal to Is playing)) and do (Actions)
        • Loop - Actions
So, the actions we put in the Loop - Actions will be set for players who are playing, only! We will use this to set the camera for the players every 0.01 seconds. Now, we will set the camera, so make a new action based on "Camera", set it to this:

  • Camera Work
    • Events
      • Time - Every 0.01 seconds of game time
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players matching (((Matching player) slot status) Equal to Is playing)) and do (Actions)
        • Loop - Actions
          • -------- You are here --------
          • Camera - Set (Picked player)'s camera Distance to target to Camera_Distance[(Player number of (Picked player))] over 0.00 seconds
This will be the camera Distance to the target, and we will set it to the variable we created before, named Camera_Distance, and we want it to be set to the Online player only thats why we have the [(Player number of (Picked Player))] because the (Picked Player) are the players from the Player Group we made.
So, every 0.01 game seconds, the trigger will the all online players camera distance. Moving on...
Next, we will make a new action. We need the camera to set the Distance, Angle and Rotation. So now we will make the Angle action. Create a new action that looks like this:

  • Camera Work
    • Events
      • Time - Every 0.01 seconds of game time
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players matching (((Matching player) slot status) Equal to Is playing)) and do (Actions)
        • Loop - Actions
          • Camera - Set (Picked player)'s camera Distance to target to Camera_Distance[(Player number of (Picked player))] over 0.00 seconds
          • -------- You are here: --------
          • Camera - Set (Picked player)'s camera Angle of attack to Camera_Angle[(Player number of (Picked player))] over 0.00 seconds
That will set the Angle every 0.01 seconds. Next is the Rotation, make a new action like this:

  • Camera Work
    • Events
      • Time - Every 0.01 seconds of game time
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players matching (((Matching player) slot status) Equal to Is playing)) and do (Actions)
        • Loop - Actions
          • Camera - Set (Picked player)'s camera Distance to target to Camera_Distance[(Player number of (Picked player))] over 0.00 seconds
          • Camera - Set (Picked player)'s camera Angle of attack to Camera_Angle[(Player number of (Picked player))] over 0.00 seconds
          • -------- You are here: --------
          • Camera - Set (Picked player)'s camera Rotation to Camera_Rotation[(Player number of (Picked player))] over 0.00 seconds
And now, this trigger is done!

Next up, is setting the Keyboard Arrow commands! These "commands" allows a player to press an keyboard arrow to change the camera!
First up is moving the camera angle Down. Make a new trigger and call it "Camera Down Press". Add this event:

  • Camera Down Press
    • Events
      • Player - Player 1 (Red) Presses the Down Arrow key
If you want it to work in Multiplayer, add these events:
[hidden="Only if Multiplayer function is wanted]
  • Camera Down Press
    • Events
      • Player - Player 1 (Red) Presses the Down Arrow key
      • Player - Player 2 (Blue) Presses the Down Arrow key
      • Player - Player 3 (Teal) Presses the Down Arrow key
      • Player - Player 4 (Purple) Presses the Down Arrow key
      • Player - Player 5 (Yellow) Presses the Down Arrow key
      • Player - Player 6 (Orange) Presses the Down Arrow key
      • Player - Player 7 (Green) Presses the Down Arrow key
      • Player - Player 8 (Pink) Presses the Down Arrow key
      • Player - Player 9 (Gray) Presses the Down Arrow key
      • Player - Player 10 (Light Blue) Presses the Down Arrow key
      • Player - Player 11 (Dark Green) Presses the Down Arrow key
      • Player - Player 12 (Brown) Presses the Down Arrow key
[/hidden]

UPDATE COMMING UP SOON!
 
Last edited:
Level 6
Joined
Apr 24, 2008
Messages
174
Use

,

and

tags and get rid of your signature.


- Done!

NOTICE: This reply will now work as my Updates box!
You will read about the thread updates here!





  • Text Changes
    • Removed colored texts and replaced with Bold
    • Removed colored texts and replaced with Underline
  • Thread Changes
    • Fixed

      ,

      and

      titles
      [*]Added more spaces between Triggers and texts




 
Last edited:
Top