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

Env shake: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
m (→‎Inputs: Substituted IO templates)
 
(44 intermediate revisions by 27 users not shown)
Line 1: Line 1:
{{wrongtitle|title=env_shake}}
{{LanguageBar}}
{{TabsBar|main=gs|base=env_shake}}  
{{Underlinked|date=January 2024}}
{{CD|CEnvShake|file1=EnvShake.cpp}}
{{This is a|point entity|name=env_shake|sprite=1}} When it receives the input <code>StartShake</code>, it shakes the screens of [[player]]s for some duration. Objects can be jostled as well.


==Entity Description==
{{tip|To get a continuous shake, one can fire the <code>StartShake</code> input at regular intervals, for example using a [[logic_timer]]. The continuous shake can then be stopped by disabling the timer.}}
[[Image:{{PAGENAME}}.png|left]]An entity to control screen shake on players.{{clr}}


==Availability==
{{note|This can greatly hinder the accuracy of shots fired when the shaking is continuous.}}
{{in game|point}} {{game-base}}
 
{{in code|class=class_c_env_shake.html CEnvShake|file=_env_shake_8cpp-source.html EnvShake.cpp}}
{{note|In code, a comment says that {{ent|UTIL_ScreenShake}} does not work on airborne players. This is false.}}
 
__NOTOC__
==Flags==
{{fl|1|GlobalShake|Ignore radius, EVERYTHING shakes.}}
{{fl|4|In Air|Shake players even if they are in mid-air. Normally, if <code>StartShake</code> 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.}}
{{fl|8|Physics|Shake physics objects, not just the camera.}}
{{fl|16|Ropes|Shake ropes. This works independently from '''Physics'''.}}
{{fl|32|DON'T shake view (for shaking ropes or physics only)}}
{{fl|64|DON'T Rumble Controller|Do not shake the controller for players using an Xbox controller, etc.}}


==Keyvalues==
==Keyvalues==
*{{kv targetname}}
{{KV Targetname}}
*{{kv parentname}}
{{KV|Amplitude (0-16)|intn=amplitude|float|How far away from the normal position the camera will wobble and objects move. For camera, should be a range between 0 and 16. For objects, can be set much higher. {{note|With high amplitudes, the player might be able to briefly look through walls that they touch.}}}}
*'''amplitude'''
{{KV|Effect Radius|intn=radius|float|The radius around this entity in which to affect players. {{note|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, <code>StopShake</code> will only stop any shaking for players within the radius.}}}}
:<float> The amount of noise in the screen shake. Should be a range between 0 and 16.
{{KV|Duration (seconds)|intn=duration|float|The length of time in which to shake the player's screens.}}
*'''radius'''
{{KV|Frequency|intn=frequency|float|How many times per second to change the direction of the camera wobble. 40 is generally enough; values higher are hardly distinguishable.}}
:<float> The radius around this entity in which to affect players.
*'''duration'''
:<float> The length of time in which to shake the player's screens.
*'''frequency'''
:<float> The frequency used to apply the screen shake. Should be a value between 0 and 255, where 0.1 = jerk, and 255.0 = rumble.


==Flags==
*1 : Shake everywhere
*4 : In Air
: Shakes objects even if they are not onground
*8 : Physics
: Shakes physics
*16 : Ropes
: Shakes ropes
*{{ep1 add|32 : No view}}
: Don't shake view


==Inputs==
==Inputs==
*{{i targetname}}
{{I|Amplitude|param=int|Sets '''Amplitude'''.}}
*{{i parentname}}
{{I|Frequency|param=int|Sets '''Frequency'''.}}
*'''Amplitude <float>'''
{{I|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.}}
:Set the amplitude (0-16)
{{I|StopShake|Stop the shake. If a radius is used, it affects only players inside it.}}
*'''Frequency <float>'''
:Set the frequence. Should be a value between 0 and 255, where 0.1 = jerk, and 255.0 = rumble.
*'''StartShake'''
:Start the shake.
*'''StopShake'''
:Stop the shake.
 
[[Image:Example.jpg]]==Outputs==
*{{o targetname}}


[[Category:Entities]]
[[Category:GUI Entities]]
[[Category:Camera]]

Latest revision as of 10:53, 21 April 2025

English (en)中文 (zh)Translate (Translate)
Underlinked - Logo.png
This article needs more Wikipedia icon links to other articles to help Wikipedia icon integrate it into the encyclopedia. Please help improve this article by adding links Wikipedia icon that are relevant to the context within the existing text.
January 2024
C++ Class hierarchy
CEnvShake
CPointEntity
CBaseEntity
C++ EnvShake.cpp
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

GlobalShake : [1]
Ignore radius, EVERYTHING shakes.
In Air : [4]
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.
Physics : [8]
Shake physics objects, not just the camera.
Ropes : [16]
Shake ropes. This works independently from Physics.
DON'T shake view (for shaking ropes or physics only) : [32]
DON'T Rumble Controller : [64]
Do not shake the controller for players using an Xbox controller, etc.

Keyvalues

Name (targetname) <string>[ Edit ]
The name that other entities refer to this entity by, via Inputs/Outputs or other keyvalues (e.g. parentname or target).
Also displayed in Hammer's 2D views and Entity Report.
See also:  Generic Keyvalues, Inputs and Outputs available to all entities

Amplitude (0-16) (amplitude) <float>
How far away from the normal position the camera will wobble and objects move. For camera, should be a range between 0 and 16. For objects, can be set much higher.
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 <integerRedirectInput/integer>
Sets Amplitude.
Frequency <integerRedirectInput/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.