the-crypt/script/Projectile.gd

17 lines
336 B
GDScript3
Raw Normal View History

extends KinematicBody2D
class_name Projectile
2020-07-17 15:31:11 -05:00
export var speed = 300
var velocity = Vector2.ZERO
func _physics_process(delta):
var collision = move_and_collide(velocity * delta)
if collision != null:
2020-07-17 19:18:59 -05:00
on_impact(collision)
2020-07-18 17:07:40 -05:00
2020-07-17 15:21:22 -05:00
func launch():
velocity = (Vector2(speed, 0)).rotated(rotation)
2020-07-17 19:18:59 -05:00
func on_impact(collision):
queue_free()