19 lines
530 B
GDScript
19 lines
530 B
GDScript
extends RigidBody2D
|
|
class_name Bullet
|
|
|
|
var player : Player
|
|
@export var flash : PackedScene = preload("res://effects/flash.tscn")
|
|
var pref : int = 0
|
|
|
|
func _integrate_forces(state) -> void:
|
|
pref += 1
|
|
if state.get_contact_count() > 0 && pref > 10:
|
|
pref = 0
|
|
var instance = flash.instantiate()
|
|
instance.global_position = state.get_contact_collider_position(0)
|
|
get_parent().add_child(instance)
|
|
|
|
|
|
func _on_body_entered(body: Node) -> void:
|
|
if body != Player and $animation.current_animation_position < 8:
|
|
$animation.seek(8)
|