Env shake: Difference between revisions
Jump to navigation
Jump to search
Tip:To get a continuous shake, one can fire the
Note:This can greatly hinder the accuracy of shots fired when the shaking is continuous.
Note:In code, a comment says that UTIL_ScreenShake does not work on airborne players. This is false.
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}} | {{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== | ||
{{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|Amplitude (0-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 | {{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) | {{KV|Duration (seconds)|intn=duration|float|The length of time in which to shake the player's screens.}} | ||
{{KV|Frequency | {{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 | {{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 | {{O BaseEntity}} | ||
[[Category:GUI Entities]] | [[Category:GUI Entities]] |
Revision as of 18:04, 14 April 2022
Template:Base point When it receives the input StartShake
, it shakes the screens of players for some duration. Objects can be jostled as well.

StartShake
input at regular intervals, for example using a logic_timer. The continuous shake can then be stopped by disabling the timer.

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