Defines the cw.thirdperson library, the chase camera behind the Third Person plugin.

On the server the chasecam console command switches a player's thirdperson networked int and view entity through cw.thirdperson.Enable and cw.thirdperson.Disable. On the client its CalcView and HUDPaint hooks place the camera behind the player and draw a crosshair at the aim point, tuned by the chasecam_* convars and the chasecam_zoom command.

Summary

Functions

Computes the third person camera view; runs as a CalcView hook.
Handles the chasecam console command: 1 enables third person, 0 disables it and no argument toggles it.
Turns third person off for a player.
Turns third person on for a player.
Draws the third person crosshair where the local player's aim hits; runs as a HUDPaint hook.
Toggles the close-up third person camera; bound to the chasecam_zoom console command.

Functions

cw.thirdperson.CalcView(player, pos, angles, fov)

client gamemodes/cwhl2rp/plugins/thirdperson/plugin/libraries/sh_thirdperson.lua:38

Computes the third person camera view; runs as a CalcView hook.

Only acts while the player's thirdperson networked int is 1. The camera sits behind and to the right of the player, offset by the chasecam_back, chasecam_right and chasecam_up convars (or close up while zoomed), is traced so it stays out of walls, and moves forward and bobs while sprinting. Position and field of view are eased when chasecam_smooth is on. Also turns the player to face the aim direction.

Parameters

  • player Player The local player
  • pos Vector The default view origin
  • angles Angle The default view angles
  • fov Number The default field of view

Returns

  • Map The view table from GAMEMODE:CalcView, or nil when third person is off

cw.thirdperson.Command(player, command, arguments)

server gamemodes/cwhl2rp/plugins/thirdperson/plugin/libraries/sh_thirdperson.lua:201

Handles the chasecam console command: 1 enables third person, 0 disables it and no argument toggles it.

Switching on is ignored within half a second of the previous switch on, since each one spawns a camera entity. Does nothing when run from the server console.

Parameters

  • player Player The player who ran the command
  • command String The console command name
  • arguments List<String> The command arguments

See also

Turns third person off for a player.

Removes the camera entity and gives the view back to the player, unless something else has taken the view over since. Does nothing when third person is already off.

Parameters

  • player Player The player to switch to first person

See also

Turns third person on for a player.

Creates an invisible prop_dynamic parented to the player, makes it the player's view entity and sets the thirdperson networked int to 1. Does nothing when third person is already on.

Parameters

  • player Player The player to switch to third person

See also

Draws the third person crosshair where the local player's aim hits; runs as a HUDPaint hook.

The crosshair grows as the target gets closer and turns red when the camera cannot see the hit position.

cw.thirdperson.Zoom(player, command, arguments)

client gamemodes/cwhl2rp/plugins/thirdperson/plugin/libraries/sh_thirdperson.lua:177

Toggles the close-up third person camera; bound to the chasecam_zoom console command.

Parameters

  • player Player The local player
  • command String The console command name
  • arguments List<String> The command arguments; unused

Defined in