Advertisement
Atonlord

Dash Ghost Effect in Godot 4

May 11th, 2023
1,620
-1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
GDScript 0.94 KB | Gaming | 0 1
  1. #Sprite2D
  2.  
  3. extends Sprite2D
  4.  
  5. func _ready():
  6.     randomize()
  7.     var tween = create_tween()
  8.     tween.tween_property(self, "modulate:a", 0.0, 0.4).set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_OUT)
  9.     tween.tween_interval(0.6)
  10.     tween.tween_callback(tween_all_completed)
  11.  
  12. func tween_all_completed():
  13.     self.queue_free()
  14.  
  15.  
  16. #------------------------------------------
  17.  
  18.  
  19. #Script that calls the function start_rush_ghost()
  20.  
  21. @onready var source: Sprite2D = $"location where the source Sprites"
  22. var sprite
  23.  
  24. func start_rush_ghost():
  25.     for i in 7:
  26.         instance_rush_ghost()
  27.         await get_tree().create_timer(0.02).timeout
  28.  
  29. func instance_rush_ghost():
  30.     var ghost: Sprite2D = rush_ghost.instantiate()
  31.     get_tree().root.add_child(ghost)
  32.  
  33.     ghost.global_position = player.global_position #Self explanatory
  34.     ghost.texture = source.texture
  35.     ghost.scale = source.scale
  36.     ghost.vframes = source.vframes
  37.     ghost.hframes = source.hframes
  38.     ghost.frame = source.frame
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement