RampRumble - ObjectReference
Jump to navigation
Jump to search
Member of: ObjectReference Script
Intended as a quick way to cause some controller and camera rumble. Automatically tapers intensity of the effect based on players distance from the point of origin/calling reference.
Syntax[edit | edit source]
bool Function rampRumble(float power = 0.5, float duration = 0.25, float falloff = 1600.0)
if power > 1.0 || power <= 0
endif
float playerDist = game.getplayer().getDistance(self)
if playerDist < falloff
float intensity = (1 - (playerDist / falloff))
intensity = intensity*power
if intensity > 1.0
intensity = 1.0
elseif intensity <= 0
intensity = 0
return false
endif
game.shakeCamera(game.getPlayer(), intensity)
game.shakeController(intensity, intensity, duration)
return true
else
return False
endif
endFunction
Parameters[edit | edit source]
- power: How powerful this rumble is at the point of origin
- Default: 0.5, which is the half intensity. Valid values are 0.001 - 1.0, with 1.0 being the most intense effect possible
- duration: how long should the effect last?
- Default: 0.25
- falloff: Radius of the effect. Most intense at calling reference, tapers to nothing at falloff distance
- Default: 1600
Return Value[edit | edit source]
Returns false if no rumble is applied. (Invalid parameter values are clamped and won't cause it to fail)
Examples[edit | edit source]
; cause some intense camera/controller rumble originating from the marker, with a small radius
; send debug traces to let me know if any rumble was caused
if (!RumbleMarker.RampRumble(1.0, 0.25, 512.0))
debug.trace("RampRumble() didn't cause any shake. Player too far away?")
else
debug.trace("player's world was rocked")
endif
; simple controller/camera shake
RumbleMarker.RampRumble()