- 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
- (Any) Warcraft World Editior
- Basic Knowledge can of course come in handy
Index1 - 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.
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.
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
-
Events
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
-
Events
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.
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>
-
Events
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>
-
Events
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
-
Events
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>
-
Events
-
End Looking Right
-
Events
- Player - Player 1 (Red) Releases the Right Arrow key
- Conditions
-
Actions
- Trigger - Turn off LookRight <gen>
-
Events
-
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
-
Events
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.
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>
-
Events
''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>
-
Events
-
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>
-
Events
-
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>
-
Events
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.
-
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!
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.
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
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
-
Events
Now it should work, if you done everything right. Hope I helped you more with this.
Part 6 - Sample RPG using this FPC
HTML:
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
Last edited: