2020-07-17 13:15:52 -05:00
|
|
|
extends KinematicBody2D
|
|
|
|
class_name Projectile
|
|
|
|
|
2020-07-17 15:31:11 -05:00
|
|
|
export var speed = 300
|
2020-07-17 13:15:52 -05:00
|
|
|
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")
|
2020-07-17 13:15:52 -05:00
|
|
|
|
|
|
|
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 13:15:52 -05:00
|
|
|
|
2020-07-17 19:18:59 -05:00
|
|
|
func on_impact(collision):
|
2020-07-17 14:10:02 -05:00
|
|
|
queue_free()
|