1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still haven't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. Ride into the sunset with the 32nd Modeling Contest. The contest is optionally paired. Best of luck, people!
    Dismiss Notice
  4. This adventure has come to an end. Congratulate our heroes in the 16th Mini Mapping Contest Results.
    Dismiss Notice
  5. From the gates of hell, the 5th Special Effect Contest Results have emerged.
    Dismiss Notice
  6. Race against the odds and Reforge, Don't Refund. The 14th Techtree Contest has begun!
    Dismiss Notice
  7. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Creating a First Person Camera

Discussion in 'Trigger (GUI) Editor Tutorials' started by Magamdy, Aug 6, 2008.

Tags:
  1. Magamdy

    Magamdy

    Joined:
    Apr 17, 2008
    Messages:
    211
    Resources:
    3
    Maps:
    2
    Tutorials:
    1
    Resources:
    3
    Creating a First Person Camera

    This Tutorial will teach you how the create a 1st Person Camera, wich is extremely useful for RPG's and a must have for a FPS (duh).

    - What do you need? -
    - (Any) Warcraft World Editior
    - Basic Knowledge can of course come in handy

    Index
    1 - The Basic Camera
    2 - Looking Around
    3 - Looking Up & Down
    4 - Tips for Maps using FPC
    5 - Second way for Looking Around
    6 - Sample RPG using this FPC

    Part 1 - The Basic Camera

    To get started we need to get ourself a basic camera. This will form the base of the camera and will include the camera height and stuff like that. It is also the camera position you will return to after looking up or down.

    Create a category called ''Camera'' with two triggers in it called ''Initialization'' and ''Camera''.

    For the Initialization:
    Use Map Initialization as Event

    Now go to Actions - Camera - Lock Camera Target To Unit and let it use Default Rotation

    Also the size of the Hero must be set to 0, otherwise you will still see the model when using the camera, so go to Animation - Change Unit Size and set the scale of your unit to zero.

    :cexc: Note: Because the size of the unit is set to zero, projectiles shot by the unit will NOT be visisble. I am currently trying to find a solution for this.
    :cexc: Note: Because the size of the unit is set to zero, footsteps will appear as one long trail. The only way to remove this is by directly editing the model and removing the footsteps. This can easily be done in the War3ModelEditor.

    Your trigger should look like this:
    • Intilization
      • Events
        • Map initialization
      • Conditions
      • Actions
        • Camera - Lock camera target for Player 1 (Red) to A unit 0001 <gen>, offset by (0.00, 0.00) using Default rotation
        • Animation - Change A unit 0001 <gen>'s size to (0.00%, 0.00%, 0.00%) of its original size



    Now on to the ''Camera'' Trigger
    As Event go to Time - Periodic Event - Every 0.01 seconds of the Game

    And for the Actions
    Go to Camera - Set Camera Field (Timed) - Set Player 1's camera Distance to Target to -700 over 0.50 seconds

    Now copy this trigger 3 times and chance the ''Distance to Target'' to "Angle of Attack", "Height Offset" and "Camera Rotation".

    Make them like this:
    • Camera
      • Events
        • Time - Every 0.01 seconds of game time
      • Conditions
      • Actions
        • Camera - Set Player 1 (Red)'s camera Distance to target to -700.00 over 0.50 seconds
        • Camera - Set Player 1 (Red)'s camera Angle of attack to 350.00 over 0.50 seconds
        • Camera - Set Player 1 (Red)'s camera Height Offset to 200.00 over 0.50 seconds
        • Camera - Set Player 1 (Red)'s camera Rotation to (Facing of A unit 0001 <gen>) over 0.50 seconds


    Now we've already got ourself a 1st Person Camera
    FPS1.jpg FPS2.jpg FPS3.jpg

    But this might be still considered as a prototype, because the options are minimum and the way of walking is quite hard. For example, if you are facing a wall in the front you need to click and click and click at the screens edge to get out of your position.

    Part 2 - Looking Around

    Back to the example of the wall, if you where able to turn around, you could easily get out of your position. Well thats exactly what we're gonna do now. We're gonna make triggers using the arrow keys that make the camera turn when you press them.

    :cexc: NOTE: In chapter 5, an alternative way for looking around is described. Read, it first, and then decide what system you are going to use, because I highly recommend the second way!

    Let's start with looking Left and Right

    Make 2 categories and call them Look left and Look Right.

    We start with left. Create 3 triggers named ''Start Looking left'', ''End Looking left'' and ''looking left''. The trigger ''Looking left must be disabled from the beginning. (Uncheck Initially On in the top of the screen.)

    Start Looking left
    Events: Player - Player 1 presses the Left Arrow Key
    Actions: Trigger - Turn on Look left


    • Start Looking Left
      • Events
        • Player - Player 1 (Red) Presses the Left Arrow key
      • Conditions
      • Actions
        • Trigger - Turn on Look Left <gen>


    End Looking left
    Events: Player - Player 1 Releases the Left Arrow Key
    Actions: Trigger - Turn off Look Left

    • End Looking left
      • Events
        • Player - Player 1 (Red) Releases the Left Arrow key
      • Conditions
      • Actions
        • Trigger - Turn off Look Left <gen>


    Looking Left
    Events: Time - Periodic Event - Every 0.01 seconds of the game

    Actions: Unit - Make Unit 0001 face (Face of Unit 0001[Same Unit]) + 10) over 0.00 seconds

    To create this action go to Units - Make Unit face Unit
    On part where you need to select which unit your unit should be facing select the Function Arithmetic instead of a unit and click the first of the two numbers.
    Make this the facing of your hero. The other number should be chanced into 10 or 15 or something, just how fast you want to look around.

    • Look Left
      • Events
        • Time - Every 0.01 seconds of game time
      • Conditions
      • Actions
        • Unit - Make A Unit 0001 <gen> face ((Facing of A Unit 0001 <gen>) + 10.00) over 0.00 seconds


    This will allow your camera to turn left if you push the Left Arrow Key and stop turning when you release the button. Well Done! Now on to Right.

    Right is almost the same thing, just copy the 3 triggers, rename them, and bring some small chances to them. They must look like this.

    • Start Looking Right
      • Events
        • Player - Player 1 (Red) Presses the Right Arrow key
      • Conditions
      • Actions
        • Trigger - Turn on LookRight <gen>


    • End Looking Right
      • Events
        • Player - Player 1 (Red) Releases the Right Arrow key
      • Conditions
      • Actions
        • Trigger - Turn off LookRight <gen>


    • Look Right
      • Events
        • Time - Every 0.01 seconds of game time
      • Conditions
      • Actions
        • Unit - Make A Unit 0001 <gen> face ((Facing of A Unit 0001 <gen>) - 9.00) over 0.00 seconds


    The only thing to do is to chance the + by Look Right into a -, but remember that Look Right must be disabled from the beginning of the game.

    You now have a far more advanced First person Camera! Well Done! But, where still not completely done, we still need to create a look up & down function.

    :cexc: Note: A lot of people would use the up and down arrow keys for a movement system, but I prefer (especially down) you to use them to look up and down. Because, if you are in first person mode, and you get, for example, ambushed by a small enemy, you couldn't look down to see what's attacking you. The same thing would be with picking up dropped items.

    Part 3 - Looking Up and Down

    Create a new category called ''Up & Down'' and put 4 triggers in it; ''Look Up'', ''Look Up Off'', ''Look Down'' and ''Look Down Off''.

    ''Look Up'' should look like this
    • Look Up
      • Events
        • Player - Player 1 (Red) Presses the Up Arrow key
      • Conditions
      • Actions
        • Camera - Set Player 1 (Red)'s camera Angle of attack to 370.00 over 0.50 seconds
        • Trigger - Turn off Camera <gen>


    Warning: You can make your Angle of Attack as high as you want, but don't let it diviate too much from the Angle of Attack of your Basic Camera. For example, if the AOA of you basic Camera is 350, and when you look up, it will chance to 400, then objects such as trees will disappear when you look up, and reappear when you return to your basic Camera

    ''Look Up off'' must look like this

    • Look Up Off
      • Events
        • Player - Player 1 (Red) Releases the Up Arrow key
      • Conditions
      • Actions
        • Camera - Set Player 1 (Red)'s camera Angle of attack to 350.00 over 0.50 seconds
        • Trigger - Turn on Camera <gen>


    ''Look Down'' and ''Look Down Off'' are nearly the same, but here the AOA will decrease.

    • Look Down
      • Events
        • Player - Player 1 (Red) Presses the Down Arrow key
      • Conditions
      • Actions
        • Camera - Set Player 1 (Red)'s camera Angle of attack to 330.00 over 0.50 seconds
        • Trigger - Turn off Camera <gen>


    • Look Down Off
      • Events
        • Player - Player 1 (Red) Releases the Down Arrow key
      • Conditions
      • Actions
        • Camera - Set Player 1 (Red)'s camera Angle of attack to 350.00 over 0.50 seconds
        • Trigger - Turn on Camera <gen>


    Gratz!!!! You now have created a fully controllable First Person Camera:thumbs_up: Hope your RPG will be great one :D

    Part 4 - Tips for Maps with a FPC

    - Make all objects much larger then in normal maps. For example; Humans must size 2 or even 3 if you want a realistic relation between the player's FPC and the NPC.

    - If you use cinematics, be sure to turn off the camera and return the unit to it full size before starting the it.

    -If you get on higher grounds, the camera won't get higher, so make regions where the Camera height will chance when walking there.

    Viva la Solutione (:\)

    Now there's finally a solution for this!


    All credits for this solution go to ap0calypse! Thanks!!

    First of all go to the Basic Camera trigger you made earlier and delete the Camera Height action.
    [trigger=Camera Basic]Camera Basic
    Events
    Time - Elapsed game time is 0.01 seconds
    Conditions
    Actions
    Camera - Set Player 1 (Red)'s camera Distance to target to -1200.00 over 0.50 seconds
    Camera - Set Player 1 (Red)'s camera Angle of attack to 350.00 over 0.50 seconds
    [/trigger]

    Now click the Variable button (The big yellow cross) and make two new variables.

    - Variable 1
    Variable Name: Loc
    Variable Type: Point

    - Variable 2
    Varialbe Name: ZHeight
    Variable Type: Real

    Leave the array check and Initial Value untouched.

    Now create a new trigger called Camera Basic Height
    It must look like this
    [trigger=Camera Basic Height]Camera Basic Height
    Events
    Time - Every 0.05 seconds of game time
    Conditions
    Actions
    Set Loc = (Position of Your Hero <gen>)
    Custom script: set udg_ZHeight = GetLocationZ(udg_Loc)
    Camera - Set Player 1 (Red)'s camera Height Offset to (ZHeight + 200.00) over 0.00 seconds
    Custom script: call RemoveLocation(udg_Loc)
    [/trigger]

    To get to the Custom Script action look under - General and copy the text the above trigger into the line.

    If right, the height of the camera should now adapt to the height of the terrain. Thanks again Ap0calypse!

    :cexc: Note: Bridges are not recognized as terrain, so the camera will not adapt to the height of the bridge, but the terrain under it. (Same case with any walkable object). This can be fixed by creating regions at the location of bridges. When the hero enter that region, the adapting camera must be disabled and a camera with constant height should be enabled. Inverse when leaving.


    -Use Dialogs as talking method. If you don't know how to make dialogs, take a look at the included map, or shearch for a Dialog tutorial on the hive.

    Part 5 - Second way for looking Around

    You may have already noticed, that you can't look left and right when your Hero is walking. This makes Mouse-Walking still kind of tricky.

    We'll, I have found a way of looking wich enables to look around also when you are walking but it comes with a few issues.

    -The Make Unit face Unit trigger doesen't work anymore

    -When you push Left or Right the camera doesen't react immediatly.

    BUT, if you use this way, walking will be far more easy when using Mouse-Walking.

    What to do First

    Go to the Basic Camera trigger and remove the
    • Camera - Set Player 1 (Red)'s camera Rotation to (Facing of Galahird 0001 <gen>) over 0.50 seconds
    Part

    Now go to the trigger Look Left and delete the Action.
    For the new action, go to Camera - Set Camera Field (Timed) - Set Players Rotation to (Choose Function - Arithmetic) [First Number = Camera Field of Camera Object = Rotation of Current Camera] - [Second Number = 3] over 0.05 seconds

    Leave the Plus. Then it should look like this
    • Look Left
      • Events
        • Time - Every 0.01 seconds of game time
      • Conditions
      • Actions
        • Camera - Set Player 1 (Red)'s camera Rotation to ((Rotation of (Current camera)) + 3.00) over 0.05 seconds


    Now Copy this Action, go to Look Right, delete that Action and paste the new Action in it. Don't forget to chance the + to a -!

    Now it should work, if you done everything right. Hope I helped you more with this.



    Part 6 - Sample RPG using this FPC
    HTML:
     
    I am working on a RPG that uses my First Person camera. I wanted to finish a little part and post it here to use as sample... But the filesize was to big -.-

    So now it's located here:
    Tutorial - Blood, Sweat and ice - The Hive Workshop - A Warcraft III Modding Site
    Plz rate the map too.

    Hope this makes everything a bit more clear ^^

    Tnx for using my Tutorial - Please Comment and give Rep :D
     
    Last edited: Jan 29, 2011
  2. thedeathunterxx

    thedeathunterxx

    Joined:
    Aug 3, 2008
    Messages:
    1,880
    Resources:
    2
    Maps:
    2
    Resources:
    2
    this is a nice tutorial.

    see i have been in map making for 4 years.
    and i still cant find a way to make the camera not go all screwy when you approach a wall, without using the arrow key movements.
     
  3. Hawkwing

    Hawkwing

    Joined:
    Nov 28, 2006
    Messages:
    5,823
    Resources:
    28
    Models:
    15
    Icons:
    3
    Packs:
    1
    Skins:
    8
    Tutorials:
    1
    Resources:
    28
    Remember to use the [b][/b], [h1][/h1], [h2][/h2], [h3][/h3] tags to make the different steps more obvious.

    Anyways, nice tutorial. Quite descriptive, the pictures are helpful too. You need to watch the smilie spam though. Nicely made, and quite simple. Though there may be a few leaks here and there.
     
  4. Devine

    Devine

    Joined:
    Sep 2, 2007
    Messages:
    3,197
    Resources:
    0
    Resources:
    0
    I learned today :)
    however i wouldnt use the up and down arrow to look up or down but to walk.
     
  5. Hawkwing

    Hawkwing

    Joined:
    Nov 28, 2006
    Messages:
    5,823
    Resources:
    28
    Models:
    15
    Icons:
    3
    Packs:
    1
    Skins:
    8
    Tutorials:
    1
    Resources:
    28
    Ya that's a big flaw. The Right-Click movement system sucks with First-Person.
     
  6. Magamdy

    Magamdy

    Joined:
    Apr 17, 2008
    Messages:
    211
    Resources:
    3
    Maps:
    2
    Tutorials:
    1
    Resources:
    3
    Yep, your're absolutely right, i used those 2 buttons for that also. But in my map you it is required to look up n' down... So I chanced it and it's in my tutorial now too =P
     
  7. Hawkwing

    Hawkwing

    Joined:
    Nov 28, 2006
    Messages:
    5,823
    Resources:
    28
    Models:
    15
    Icons:
    3
    Packs:
    1
    Skins:
    8
    Tutorials:
    1
    Resources:
    28
    Anyways, the tutorial itself is nice. It works. It just might not be prefered by some people.
     
  8. Magamdy

    Magamdy

    Joined:
    Apr 17, 2008
    Messages:
    211
    Resources:
    3
    Maps:
    2
    Tutorials:
    1
    Resources:
    3
    Got a New Method of Looking - It's located at the end of the tut
     
  9. Oziris

    Oziris

    Joined:
    Oct 14, 2006
    Messages:
    4,109
    Resources:
    3
    Icons:
    1
    StarCraft II Resources:
    1
    Tutorials:
    1
    Resources:
    3
    Nice tutorial but i hate to do a map that has 11 players becous u have to do for player 1,2,3,4....making the same triggers again and again....then i get bored to death and do something else.
     
  10. Magamdy

    Magamdy

    Joined:
    Apr 17, 2008
    Messages:
    211
    Resources:
    3
    Maps:
    2
    Tutorials:
    1
    Resources:
    3
    Yep, but it is made for 1 or 2 players. And if you wanna made itfor 12 players, it's just takes some time, but it's just copying and pasting the same triggers. Isn't too hard if you question me.
     
  11. UnholyDobry

    UnholyDobry

    Joined:
    Jul 27, 2008
    Messages:
    121
    Resources:
    5
    Icons:
    5
    Resources:
    5
    Yea copying wont be to hard gotha say nice tutorial whoud give u rep if i coud :cool:
     
  12. KingWolf

    KingWolf

    Joined:
    Aug 25, 2008
    Messages:
    5
    Resources:
    0
    Resources:
    0
    Thank God Someone made this!
     
  13. nesatauri

    nesatauri

    Joined:
    Jun 6, 2008
    Messages:
    42
    Resources:
    0
    Resources:
    0
    I was about to go off on a rant on how you handle looking up and looking down, since it looks like what you did was a really nooby mistake. Since its the camera target that is fixed in position in wc3 and not the camera source, simply changing the angle of attack would move the camera source up and down, possibly putting the camera way above the unit's head or below the unit's feet instead of keeping the camera source where it is and actually looking up and down like you want.

    This is a big part of the headache of creating a good first person camera. Since wc3's cameras are geared toward third person perspectives, fine control over the camera source is non-existent. You have to manipulate the camera source via manipulations of the camera target, angle of attack, and distance to camera. It involves a lot of trigonometry.

    However, you use a negative distance to target. Honestly, I haven't ever tried negative values for that, and its possible that its the solution to my angle of attack woes.:razz: However, your warning about deviating from the angle of attack too much kinda tells me its not.

    Oh, my, I ranted anyway. LOL
     
  14. Magamdy

    Magamdy

    Joined:
    Apr 17, 2008
    Messages:
    211
    Resources:
    3
    Maps:
    2
    Tutorials:
    1
    Resources:
    3
    Guy, have you tested my camera? Becouse Angle of Attack does NOT put the camera above the head or beneath the feet of the character, that's what Height Ofsett does...
     
  15. Cheezeman

    Cheezeman

    Joined:
    Aug 19, 2008
    Messages:
    488
    Resources:
    2
    Spells:
    1
    Tutorials:
    1
    Resources:
    2
    why does my character keep spinning?
     
  16. Magamdy

    Magamdy

    Joined:
    Apr 17, 2008
    Messages:
    211
    Resources:
    3
    Maps:
    2
    Tutorials:
    1
    Resources:
    3
    Well, i know two reasons...

    1= You've forgot to create the trigger that stops the camera turning when you release a button.

    2= This is a bug i discovered in my map. While i was pressing left to look left, a dialog showed up. When the dialog ended the camera keeps rotating. Simple conlcusion; just press left again and it stops spinnig...
     
    Last edited: Sep 8, 2008
  17. Cheezeman

    Cheezeman

    Joined:
    Aug 19, 2008
    Messages:
    488
    Resources:
    2
    Spells:
    1
    Tutorials:
    1
    Resources:
    2
    The second conclution is probobly right beacuse it says that I won when the game starts.
    And yes, it stoped spinning when I pressed left key. What I do not understand is why he keeps headbanging all the time! (Is the facingpoint the point which his head is facing?)
     
  18. Alkser

    Alkser

    Joined:
    Aug 14, 2008
    Messages:
    7
    Resources:
    0
    Resources:
    0
    Very nice tutorial and it really works! :)
     
  19. Magamdy

    Magamdy

    Joined:
    Apr 17, 2008
    Messages:
    211
    Resources:
    3
    Maps:
    2
    Tutorials:
    1
    Resources:
    3
    Of course it works, otherwise I would not have posted it -.-
     
  20. Magamdy

    Magamdy

    Joined:
    Apr 17, 2008
    Messages:
    211
    Resources:
    3
    Maps:
    2
    Tutorials:
    1
    Resources:
    3
    Sorry for multi-post:hohum: but...

    I am making some kind of RPG with my FPC. I don't feel like finishing it completely but if I finished a big part i will maybe post it here as some kind of sample =P