diff options
Diffstat (limited to 'Scripts/Weapons/Projectile.gd')
-rw-r--r-- | Scripts/Weapons/Projectile.gd | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Scripts/Weapons/Projectile.gd b/Scripts/Weapons/Projectile.gd new file mode 100644 index 0000000..fa13c70 --- /dev/null +++ b/Scripts/Weapons/Projectile.gd @@ -0,0 +1,19 @@ +extends RigidBody2D + +@export var init_vel : Vector2 +@export var sprite : Node2D +@export var atk : int + +func _ready() -> void: + linear_velocity = init_vel + print(linear_velocity.normalized()) + +func _process(delta: float) -> void: + var normalised = linear_velocity.normalized() + sprite.rotation = atan2(normalised.y, normalised.x) + +func _on_area_2d_body_entered(body:Node2D) -> void: + print(body) + if body is Entity: + body.damage(atk) + queue_free() |