ShakeCamera: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Adjust version.)
m (Note)
Line 4: Line 4:
This function allows you to trigger camera shake effect (just like explosion does).
This function allows you to trigger camera shake effect (just like explosion does).
}}
}}
{{Note|The camera shaking duration depends on the force. High values ​​can result in very long durations. If you want to cancel such a state, you should call this function with a very small force value, e.g. 0.01}}


==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool shakeCamera ( float power, [ float x, float y, float z ] )
bool shakeCamera ( float force, [ float x, float y, float z ] )
</syntaxhighlight>  
</syntaxhighlight>  


===Required arguments===
===Required arguments===
*'''power''': Intensity and time of the shake.
*'''force''': Intensity and time of the shake. The higher the value, the longer the camera shakes


===Optional Arguments===
===Optional Arguments===

Revision as of 15:51, 28 July 2024

BETA: NEW FEATURE (BUILD: 1.6.0 r22631)

This function allows you to trigger camera shake effect (just like explosion does).

[[{{{image}}}|link=|]] Note: The camera shaking duration depends on the force. High values ​​can result in very long durations. If you want to cancel such a state, you should call this function with a very small force value, e.g. 0.01

Syntax

bool shakeCamera ( float force, [ float x, float y, float z ] )

Required arguments

  • force: Intensity and time of the shake. The higher the value, the longer the camera shakes

Optional Arguments

  • x: Center X coordinate of the shake.
  • y: Center Y coordinate of the shake.
  • z: Center Z coordinate of the shake.

If not given, it will defaults to local player position.

Returns

Always returns true.

Example

This example allows you to constantly trigger camera shake effect in center of the map, the closer you are to center the stronger effect will be.

local shakeStrength = 1.4 -- define strength of the camera shake
local shakePosX, shakePosY, shakePosZ = 0, 0, 3 -- define position where camera shake would happen

function triggerCameraShake()
	shakeCamera(shakeStrength, shakePosX, shakePosY, shakePosZ) -- trigger camera shake
end
setTimer(triggerCameraShake, 100, 0) -- call this function indefinitely, every 100 ms

See Also