You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
563 B
25 lines
563 B
2 years ago
|
extends KinematicBody
|
||
|
|
||
|
const BULLET_VELOCITY = 20
|
||
|
|
||
|
var time_alive = 5
|
||
|
var hit = false
|
||
|
|
||
|
onready var animation_player = $AnimationPlayer
|
||
|
onready var collision_shape = $CollisionShape
|
||
|
|
||
|
func _physics_process(delta):
|
||
|
if hit:
|
||
|
return
|
||
|
time_alive -= delta
|
||
|
if time_alive < 0:
|
||
|
hit = true
|
||
|
animation_player.play("explode")
|
||
|
var col = move_and_collide(-delta * BULLET_VELOCITY * transform.basis.z)
|
||
|
if col:
|
||
|
if col.collider and col.collider.has_method("hit"):
|
||
|
col.collider.hit(col)
|
||
|
collision_shape.disabled = true
|
||
|
animation_player.play("explode")
|
||
|
hit = true
|