fix: empty out all gridmap layers under candy pump and use precise duration timer for projectile destruction
This commit is contained in:
@@ -115,17 +115,21 @@ func spawn_projectile(target_world_pos: Vector3, duration: float) -> void:
|
||||
|
||||
var mid_y = max(global_position.y, target_world_pos.y) + 4.0
|
||||
var tween_y = create_tween()
|
||||
|
||||
# Important: Make sure both halves of the y-tween together equal `duration`
|
||||
tween_y.tween_property(projectile, "global_position:y", mid_y, duration / 2.0).set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_OUT)
|
||||
tween_y.tween_property(projectile, "global_position:y", target_world_pos.y, duration / 2.0).set_trans(Tween.TRANS_QUAD).set_ease(Tween.EASE_IN).set_delay(duration / 2.0)
|
||||
tween_y.tween_property(projectile, "global_position:y", target_world_pos.y, duration / 2.0).set_trans(Tween.TRANS_QUAD).set_ease(Tween.EASE_IN)
|
||||
|
||||
# Add some spin to the projectile
|
||||
var spin_tween = create_tween()
|
||||
spin_tween.set_loops()
|
||||
spin_tween.tween_property(projectile, "rotation", Vector3(PI*2, PI*2, PI*2), 0.5).as_relative()
|
||||
|
||||
tween.chain().tween_callback(func():
|
||||
spin_tween.kill()
|
||||
projectile.queue_free()
|
||||
# We need to wait for the X/Z tween to finish, but since it's parallel we can just use a separate timer or tween
|
||||
# to kill the projectile exactly when duration is reached, ensuring it doesn't get killed early by X/Z finishing 1 frame earlier than Y
|
||||
get_tree().create_timer(duration).timeout.connect(func():
|
||||
if is_instance_valid(spin_tween): spin_tween.kill()
|
||||
if is_instance_valid(projectile): projectile.queue_free()
|
||||
)
|
||||
|
||||
func can_rpc() -> bool:
|
||||
|
||||
Reference in New Issue
Block a user