• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Creating a First Person Camera

Level 8
Joined
Apr 17, 2008
Messages
212
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:
Level 8
Joined
Apr 17, 2008
Messages
212
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.

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.
 
Level 3
Joined
Jun 6, 2008
Messages
51
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
 
Level 8
Joined
Apr 17, 2008
Messages
212
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

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...
 
Level 8
Joined
Apr 17, 2008
Messages
212
why does my character keep spinning?

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:
Level 10
Joined
Aug 19, 2008
Messages
491
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...

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?)
 
Level 6
Joined
Aug 5, 2006
Messages
126
I think I'm necroposting but I have something to tell...

I love the tutorial, especially the whole fact that the First Person Camera system you made is slightly similar to "Arx Fatalis"...but there is one problem though, if you get attacked by an enemy, could you try to make the camera (with the player of course) face the enemy??
 
Level 8
Joined
Apr 17, 2008
Messages
212
I think I'm necroposting but I have something to tell...

I love the tutorial, especially the whole fact that the First Person Camera system you made is slightly similar to "Arx Fatalis"...but there is one problem though, if you get attacked by an enemy, could you try to make the camera (with the player of course) face the enemy??


Mmmm... Interesting question... Well the player automaticley faces the enemy to attack, but i think this camera doesn't. There should be a way to fix it, tnx for yer question^^
 
Level 1
Joined
Jan 16, 2009
Messages
1
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 wich unit your unit should be facing select the Function Arithmetic instead of a unit and click the first of the two numbers.

Erhm, I didn't get this part!

What is the "Function Arithmetic"? I can't find it in my WE, is it a variable or is it supposed to be in "Functions"?

Reply would be appreciated! :)

rlly nice tutorial otherwise
 
Level 5
Joined
Mar 5, 2009
Messages
135
This is not healthy...... I got sick after watching my character walk around for awhile....
*BLARGH*
 
Level 4
Joined
Jul 30, 2008
Messages
41
this is very good! i created with your "look left" and "look right" triggers as model, a move forward and a move backward trigger. with this you can look around while you are walking. it works very well. And your camera system is very easy and very good too! 5/5
 
Level 8
Joined
Apr 11, 2009
Messages
257
On the Part:
To create this action go to Units - Make Unit face Unit
"On part where you need to select wich 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 chanced into 10 or 15 or something, just how fast you want to look around.

The one in Bold I don't understand, can u make it clearer?
 
Level 10
Joined
Feb 22, 2008
Messages
619
uhhh...ur wrong and obviously most people here know more about triggers than you because it doesn't make the camera go over and under the unit, it makes you face up, and down...so next time you should test the tutorial or atleast do some research about what ur gunna say before you rant or then you look like an idiot...

see i ranted but for a good cause and if you read this ur probably kinda mad at me right now because i know i would be mad at me

because im just awesome that was

so

HA!
 
Level 2
Joined
May 10, 2009
Messages
8
How do you make the buttons move with W, A, S and D? Cause i just realized that in some maps, they move the characters with the W, A, S and D.

And plus, how do you make your unit so you can see the arms/shield/gun/weapon/etc. i tried other numbers for height and stuff, but all i see is inside the model. P.S. i removed the animation (0.00%, 0.00%, 0.00%) thingy.
 
Last edited:
Level 8
Joined
Apr 17, 2008
Messages
212
uhhh...ur wrong and obviously most people here know more about triggers than you because it doesn't make the camera go over and under the unit, it makes you face up, and down...so next time you should test the tutorial or atleast do some research about what ur gunna say before you rant or then you look like an idiot...

see i ranted but for a good cause and if you read this ur probably kinda mad at me right now because i know i would be mad at me

because im just awesome that was

so

HA!

Who are you talking to? me or sumbuddy else =\
 
Level 8
Joined
Apr 17, 2008
Messages
212
If...
  • 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
Is what you mean... Then:

- Go to Unit -> Make Unit face Angle
- Make ''Unit'' face...
- Now select Arithmetic at ''Function''
- Click the first number, scroll down and select ''Unit - Facing Angle''
- ''Facing of'' the same unit at ''Make Unit Face''
- Set the plus to minus and set 0 to 9 over 0 seconds

Hope that helps ^^ If it doesn't', don't mind to ask again.
 
Level 9
Joined
May 23, 2009
Messages
422
Th tutorial is awesome,but sadly i do not need it...
Still its the effort that counts...
I will give you +REP...
Good Luck on your next tutorial!
 
Top