class_name Springboard extends Area3D @export var launch_speed: float = 10.0 @export var audio_player: AudioStreamPlayer3D func _ready() -> void: body_entered.connect(_on_body_entered) func _on_body_entered(body: PhysicsBody3D) -> void: var rbody := body as RigidBody3D var ch := body as Character if rbody: scale.y = 2.0 rbody.apply_central_impulse(rbody.mass*( launch_speed*global_basis.y - rbody.linear_velocity.project(global_basis.y) )) if ch: ch.ground_normal = global_basis.y ch.soft_force_change_state(&'launch') else: audio_player.play() func _physics_process(delta: float) -> void: scale.y = lerp(scale.y, 1.0, 1.0 - 0.75**delta)