added in sprite wobble

This commit is contained in:
2025-07-19 05:54:34 +10:00
parent 92f7eb6da4
commit 736db0e160
5 changed files with 146 additions and 73 deletions

View File

@@ -55,6 +55,10 @@ var xAmp = 0.0
var yFrq = 0.0
var yAmp = 0.0
#Rotation Wobble
var rFrq = 0.0
var rAmp = 0.0
#Rotational Drag
var rdragStr = 0
var rLimitMax = 180
@@ -331,10 +335,14 @@ func rotationalDrag(length,delta):
var yvel = (length * rdragStr)
#Calculate Max angle
yvel = clamp(yvel,rLimitMin,rLimitMax)
sprite.rotation = lerp_angle(sprite.rotation,deg_to_rad(yvel),0.25)
# Add rotation wobble as percentage of rotational limits range
var rotationRange = rLimitMax - rLimitMin
var rotationWobble = sin(tick*rFrq) * (rotationRange * rAmp * 0.01)
var totalRotation = yvel + rotationWobble
sprite.rotation = lerp_angle(sprite.rotation,deg_to_rad(totalRotation),0.25)
func stretch(length,delta):
var yvel = (length * stretchAmount * 0.01)

View File

@@ -42,6 +42,12 @@ func setImage():
$WobbleControl/yFrq.value = Global.heldSprite.yFrq
$WobbleControl/yAmp.value = Global.heldSprite.yAmp
$WobbleControl/rFrqLabel.text = "rotation frequency: " + str(Global.heldSprite.rFrq)
$WobbleControl/rAmpLabel.text = "rotation percentage: " + str(Global.heldSprite.rAmp) + "%"
$WobbleControl/rFrq.value = Global.heldSprite.rFrq
$WobbleControl/rAmp.value = Global.heldSprite.rAmp
$Rotation/rDragLabel.text = "rotational drag: " + str(Global.heldSprite.rdragStr)
$Rotation/rDrag.value = Global.heldSprite.rdragStr
@@ -139,6 +145,15 @@ func _on_y_amp_value_changed(value):
Global.heldSprite.yAmp = value
func _on_r_frq_value_changed(value):
$WobbleControl/rFrqLabel.text = "rotation frequency: " + str(value)
Global.heldSprite.rFrq = value
func _on_r_amp_value_changed(value):
$WobbleControl/rAmpLabel.text = "rotation amplitude: " + str(value) + "%"
Global.heldSprite.rAmp = value
func _on_r_drag_value_changed(value):
$Rotation/rDragLabel.text = "rotational drag: " + str(value)
Global.heldSprite.rdragStr = value

File diff suppressed because one or more lines are too long