the-crypt/ai/Script/EnemyProjectile.gd
2020-07-23 11:36:28 -05:00

24 lines
577 B
GDScript

extends KinematicBody2D
class_name EnemyProjectile
export var speed = 150
var velocity = Vector2.ZERO
var damage = 0.5
func _physics_process(delta):
var collision = move_and_collide(velocity * delta)
if collision != null:
on_impact(collision)
func launch_rotated():
velocity = (Vector2(speed, 0)).rotated(rotation)
func launch_vector(vector):
velocity = vector.normalized() * speed
func on_impact(collision):
if collision.collider.has_method("get_type") && collision.collider.get_type() == "player":
var c = collision.collider
c.health -= damage
queue_free()