the-crypt/magic/Projectiles/Projectile.gd

19 lines
436 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
2020-07-19 17:19:31 -05:00
onready var Hit = get_node("Node/Hit")
onready var Hit_Wall = get_node("Node/Hit Wall")
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-19 18:36:36 -05:00
func launch(wand, effect):
2020-07-17 15:21:22 -05:00
velocity = (Vector2(speed, 0)).rotated(rotation)
2020-07-17 19:18:59 -05:00
func on_impact(collision):
queue_free()