extends Tween
class_name CameraShaker
export var camera_path : NodePath
var camera :Camera = null
func _ready():
camera = get_node_or_null(camera_path)
func disturb_offset(strength : float):
camera.h_offset = rand_range(-strength,strength)
camera.v_offset = rand_range(-strength,strength)
func shake(strength : float,duration : float = 1.0):
if camera != null:
interpolate_method(self,"disturb_offset",strength,0,duration,Tween.TRANS_SINE,Tween.EASE_OUT,0)
start()
Godot Engine:屏幕振动效果的实现
最新推荐文章于 2024-05-23 17:44:34 发布