Você está na página 1de 8

Third Person Camera in 8 quick and easy steps:

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.

Here’s an image to illustrate everything that we need:

Everything you see here is going to be explained in details later on.

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.

This is how the O/I set up should look like:

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.

2. Point_Client_Command : This entity is used to fire various console commands that we


simply type in the parameters. You only need one but you will probably use it a lot.
Name it PCC or PointClientCommand.

Here are the basic commands you will need on MapSpawn to make it work:

Sv_cheats 1 : turns cheats on

exec thirdperson: executes the thirdperson mode

Cam_idealyaw 1: sets TPS camera properties

Ent_fire headcrab setanimation Idle01: fire a starting animation

Ent_fire headcrab setparent !player: attaches the headcrab to the player. (replace “headcrab”
with whatever npc you want)

M_pitch 0: disables mouse look up and down


3. Point_View_Control : This is the camera type we will use for the third person view.
Parent it to the !player and check only the infinite hold time. Play with various options
to make it like you want. You can make static cameras that looks at the player or
dynamic cameras that follow the player wherever he goes.

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.

This is what the O/I set up should look like:

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).

5. Logic_compare (left right)

OnEqualTo = When player presses neither of those keys.

OnGreaterThan = When player presses Right (D key)

OnLessThan = When player presses Left (A key)


6. Logic_compare (forward-back)

OnEqualTo= When the player presses neither of those keys.

OnGreatherThan= When the player presses forward (W key)

OnLessThan= When the player presses back (S key)

0= False (for the logic_branch)

1=True (for the logic_branch)

As you can see we are setting animations depending on what button the player presses.

Here’s the animations I use for the headcrab:

W= Run1

S= Drown

A= TurnLeft

D= TurnRight

Left MouseClick ( Normal attack) = jumpattack_broadcast

E (Special Attack) = canal5b_sewer_jump

Not pressing anything = Idle01


If you want alyx, breen or any other model, you will have to use different animations. Use the
model’s sequence browse list to preview animations and choose the ones you like most. What
you think would work better for each movement.

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

Run and stoprun are the names I gave to my 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.

Special attacks and contextual gameplay:

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_crouchheightofs | Sets the height of the thirdperson camera while crouching

cam_standheightofs | Height of the camera while standing in thirdperson view

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 | When set to 1, the third person camera is locked

cam_fixcamera_highpos | Largest height of fixed camera position in thirdperson

cam_fixcamera_lowpos | Lowest height of fixed camera position in thirdperson

cam_livemode | Live camera mod in thirdperson This creates a shaking "Cloverfield"


style effect when the "cam_fixcamera" command is being used.

cam_fixcamera_changepos | Fixed camera modify This changes the angle of the fixed
camera

cam_fixcamera_speed1 | The speed of the chase of fixed camera

cam_fixcamera_speed2 | The speed of the death chase cam of a fixed camera

cam_targetline | Enables or disables an aiming line from the crosshair. 0 or 1.

cam_nocollide 1 This way your view doesn't bounce off walls.

cl_playermodel models/player/modelname.mdl Chooses Playermodel from you player


folder.

Você também pode gostar