This article's documentation is for anything that uses the Source engine. Click here for more information.

env_shake

From Valve Developer Community
Jump to: navigation, search
Underlinked - Logo.png
This article needs more links to other articles to help integrate it into the encyclopedia. Please help improve this article by adding links that are relevant to the context within the existing text.
January 2024
English (en)中文 (zh)
... Icon-Important.png
class hierarchy
CEnvShake defined in EnvShake.cpp
CPointEntity
CBaseEntity
Env shake.png

env_shake is a point entity available in all Source Source games. When it receives the input StartShake, it shakes the screens of players for some duration. Objects can be jostled as well.

Tip.pngTip:To get a continuous shake, one can fire the StartShake input at regular intervals, for example using a logic_timer. The continuous shake can then be stopped by disabling the timer.
Note.pngNote:This can greatly hinder the accuracy of shots fired when the shaking is continuous.
Note.pngNote:In code, a comment says that UTIL_ScreenShake does not work on airborne players. This is false.


Flags

  •  [1] : GlobalShake
       Ignore radius, EVERYTHING shakes.
  •  [4] : In Air
       Shake players even if they are in mid-air. Normally, if StartShake is fired while a player is in mid-air, they don't get any shaking at all even if they land before the shaking would end.
  •  [8] : Physics
       Shake physics objects, not just the camera.
  •  [16] : Ropes
       Shake ropes. This works independently from Physics.
  •  [32] : DON'T shake view (for shaking ropes or physics only)
  •  [64] : DON'T Rumble Controller
       Do not shake the controller for players using an Xbox controller, etc.

Keyvalues


Targetname:
Name (targetname) <string>
The targetname that other entities refer to this entity by.
Amplitude (0-16) (amplitude) <float>
How far away from the normal position the camera will wobble. Should be a range between 0 and 16.
Note.pngNote:With high amplitudes, the player might be able to briefly look through walls that they touch.
Effect Radius (radius) <float>
The radius around this entity in which to affect players.
Note.pngNote:Players within the effect radius will be affected by the shaking for the set duration, regardless of whether they remain within the radius after the shaking begins. Also, StopShake will only stop any shaking for players within the radius.
Duration (seconds) (duration) <float>
The length of time in which to shake the player's screens.
Frequency (frequency) <float>
How many times per second to change the direction of the camera wobble. 40 is generally enough; values higher are hardly distinguishable.


Inputs

Amplitude <integer>
Sets Amplitude.
Frequency <integer>
Sets Frequency.
StartShake
Start the shake. If a radius is used, it affects only players inside it and the shake amplitude for a player depends on their distance to the shake entity. Multiple shake starts at once do add up.
StopShake
Stop the shake. If a radius is used, it affects only players inside it.