Escolar Documentos
Profissional Documentos
Cultura Documentos
We don’t need programmers or C++ to make a third person view in hammer. There is a way to
simulate it effectively and create that illusion. The illusion works this way: You parent an
npc/prop_dynamic to the !player and set various movement animations through the game_ui
entity. Then you place a camera where you want and adjust it’s angle and properties.
Create a simple room and place an info_player_start where you want the player to start (duh).
To make it all work right, you need a few things first. Starting with a logic_auto, a
point_clientcommand, a point_view control and a game_ui. Start by placing these various
entities anywhere in the room (preferably close to the logic_auto and the player start point)
Note: This is how they use to do it in ep1. It also works in ep2 but not as well apparently. There’s
probably an easier way to make this work but right now this is all I know. I will try to make
another tutorial later or next week.
1. Logic_auto : This entity is used to trigger stuff on MapSpawn. The first thing you need to
do is execute a few console commands and enable the TPS camera.
Notice what is done on MapSpawn. Cheats are turned on. Thirdperson mode is turned on. Our
camera is enabled. The headcrab is parented to the player. A starting animation is set. And the
mouse look up and down is disabled.
Note: PCC is our point_clientcommand entity (name it whatever you like). Commands will be
explained later on. The “ThirdPersonCamera” you see is our point_viewcontrol.
Here are the basic commands you will need on MapSpawn to make it work:
Ent_fire headcrab setparent !player: attaches the headcrab to the player. (replace “headcrab”
with whatever npc you want)
4. Game_UI : This is the magical entity that makes it all possible. This entity can actually
recognize player movement. It knows when the player presses the WASD keys and when
the player presses the left mouse click button. This entity starts disabled and you need
to activate it through a trigger_once. This is because the logic_auto is not powerful
enough to do this on map spawn.
PressedAttack = when the player presses the left click mouse button.
XAxis (logic_compare for LR) = compares left movement versus right movement (A-D
keys).
YAxis (logic_compare for FB) = compares forward movement versus back movement
(W-S keys).
As you can see we are setting animations depending on what button the player presses.
W= Run1
S= Drown
A= TurnLeft
D= TurnRight
But what if you want a running animation for when the player runs? That’s where the
logic_relays and the logic_branch come into play.
Note: This is if and only IF you want the player to be able to run.
7. Logic_branch: This entity is used to simply enable and disable the “running” logic_relays
0=False
1= True
8. Logic_relay: These entities will dictate what speed the player moves and what
animation is set when the player walks or runs.
As you can see I use the exact same animation for walking and running. This is because
the headcrab doesn’t have a walking animation. All that changes here is the speed of
the player.
The rest is not required but is kind of important if you want to make a platformer and
want your player to be able to attack and use special attacks.
You can parent a func_button with (nodraw texture) to the model if you want
contextual gameplay and/or the ability to use a special attacks. This button will be
activated when the player presses the E key.
In my example, the button fires a special attack animation, plays a cool sound and
enables a hurt_trigger parented to the headcrab:
I put a delay of 1.5 seconds because that’s about what it takes for the animation to be
performed.
Once you hurt someone with the special attack, the hurt_trigger will be disabled and the
func_button will be locked for 5 seconds. This is to make the firerate more decent. I
want it to take 5 seconds to charge up the player’s “special gauge”. You can change the
delay to whatever you feel is right.
I have 2 hurt_triggers. The “normal attack” that is enabled when the player uses left
click. And the “special attack” that is enabled when the player presses the E key.
You can use special effects like env_lasers, env_lightglow and some ambient_generic to
make your special attacks look cool.
Note: I only check “NPCs” on the flags so that it doesn’t disable when you hit anything
else. You can check everything but be careful not to place your hurt triggers within
reach of the player and his model.
Don’t forget to put some lights in or else it’s going to be pitch black.
That’s it! Run your map and have fun experimenting with the cameras and animations.
Adjusting the camera with console commands
Here’s a list of different things you can do on MapSpawn and via the point_clientcommand. I
haven’t tested them all yet. So I can’t really tell you if this all works. I believe some of these work
only for counter strike.
cam_idealdist | Sets the distance between the camera in third person and the player model
cam_idealpitch | Sets the pitch of the thirdperson camera 90 is a top down view
cam_idealyaw | Sets the yaw of the first person camera Yaw is the tilt of the side of the
camera
cam_sideofs | Sets the left and right position of the thirdperson camera Higher the
number,
the further to the right.
cam_nottransmodel | When set to 1 You can't see through yourself like a ghost.
(Reccomended)
cam_fixcamera_changepos | Fixed camera modify This changes the angle of the fixed
camera