Garry's Mod Wiki

util.ScreenShake

  util.ScreenShake( Vector pos, number amplitude, number frequency, number duration, number radius, boolean airshake = false, CRecipientFilter filter = nil )

Description

Makes the screen shake.

The screen shake effect is rendered by modifying the view origin on the client. If you override the view origin in GM:CalcView you may not be able to see the shake effect.

Arguments

1 Vector pos
The origin of the effect.

Used serverside only, to determine which clients the event should be networked to.

2 number amplitude
The strength of the effect. How far away from its origin the camera will move while shaking.
3 number frequency
How many times per second to change the direction of the camera wobble. 40 is generally enough; values higher are hardly distinguishable.
4 number duration
The duration of the effect in seconds.
5 number radius
The range from the origin within which views will be affected, in Hammer units.

This is used when networking the event to clients only.

6 boolean airshake = false
Whether players in the air should also be affected.

Used serverside only to determine which clients to send the event to.

7 CRecipientFilter filter = nil
If set, will only network the screen shake event to players present in the filter.
This was recently added in version (2024.02.17). It might only be available on the Dev Branch right now.

Example

This will shake the screen, from the position 0, 0, 0 (X, Y, Z) and 5000 units away, with 5 amp, frequency 5, for 10 seconds.

util.ScreenShake( Vector(0, 0, 0), 5, 5, 10, 5000 )