Env shake: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
m (Clarification on the "Radius" keyvalue.)
(Added idea on how to create and control a continuous shake. Player view can go through walls. StopShake is also affected by radius. Multiple shakes add up. Used Template:fl.)
Line 1: Line 1:
{{lang|Env shake}}
{{lang|Env shake}}
{{base point|env_shake|sprite=1}} It shakes the screens of players. Objects can be jostled as well.
{{base point|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.
 
{{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.}}


{{note|This can greatly hinder the accuracy of shots fired when the shaking is continuous.}}
{{note|This can greatly hinder the accuracy of shots fired when the shaking is continuous.}}
Line 9: Line 11:


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


==Keyvalues==
==Keyvalues==
{{KV|Amplitude (0-16) (amplitude)|float|How far away from the normal position the camera will wobble. Should be a range between 0 and 16.}}
{{KV|Amplitude (0-16)|intn=amplitude|float|How far away from the normal position the camera will wobble. Should be a range between 0 and 16. {{note|With high amplitudes, the player might be able to briefly look through walls that they touch.}}}}
{{KV|Effect Radius (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.}}}}
{{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.}}}}
{{KV|Duration (seconds) (duration)|float|The length of time in which to shake the player's screens.}}
{{KV|Duration (seconds)|intn=duration|float|The length of time in which to shake the player's screens.}}
{{KV|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.}}
{{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.}}
{{KV BaseEntity|css=1}}
{{KV BaseEntity}}


==Inputs==
==Inputs==
{{IO|Amplitude|param=int|Sets '''Amplitude'''.}}
{{IO|Amplitude|param=int|Sets '''Amplitude'''.}}
{{IO|Frequency|param=int|Sets '''Frequency'''.}}
{{IO|Frequency|param=int|Sets '''Frequency'''.}}
{{IO|StartShake|Start the shake.}}
{{IO|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.}}
{{IO|StopShake|Stop the shake.}}
{{IO|StopShake|Stop the shake. If a radius is used, it affects only players inside it.}}
{{I BaseEntity}}
{{I BaseEntity}}


==Outputs==
==Outputs==
{{O BaseEntity|l4d=1}}
{{O BaseEntity}}


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

Revision as of 18:04, 14 April 2022

English (en)中文 (zh)Translate (Translate)

Template:Base point 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.
C++ In code, it is represented by theCEnvShakeclass, defined in theEnvShake.cppfile.

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

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


Outputs