Difference between revisions of "RampRumble - ObjectReference"

From the CreationKit Wiki
Jump to navigation Jump to search
imported>Jlundin
 
imported>Thingy Person
 
(One intermediate revision by one other user not shown)
Line 7: Line 7:
== Syntax ==
== Syntax ==
<source lang="papyrus">
<source lang="papyrus">
bool Function RampRumble(float power = 0.5, float duration = 0.25, float falloff = 1600.0)
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
</source>
</source>


Line 25: Line 44:
; cause some intense camera/controller rumble originating from the marker, with a small radius
; 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
; send debug traces to let me know if any rumble was caused
if (!RumbleMarker.RampRumble(1.0, 0.25, 512))
if (!RumbleMarker.RampRumble(1.0, 0.25, 512.0))
     debug.trace("RampRumble() didn't cause any shake.  Player too far away?")
     debug.trace("RampRumble() didn't cause any shake.  Player too far away?")
else
else

Latest revision as of 17:00, 29 June 2013

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()

See Also[edit | edit source]