CyberTower/scripts/bullet.gd

19 lines
435 B
GDScript3
Raw Normal View History

2024-02-16 12:35:30 +00:00
extends CharacterBody2D
@export var damage = 12.0
2024-02-16 15:35:39 +00:00
@export var knockback = 4
2024-02-16 12:35:30 +00:00
func _physics_process(delta):
var collision = move_and_collide(velocity * delta)
if collision:
var collider = collision.get_collider()
if collider is Enemy:
2024-02-16 15:35:39 +00:00
var normal = collision.get_normal()
collider.velocity = collider.velocity.bounce(normal) * knockback
2024-02-16 12:35:30 +00:00
collider.take_damage(damage)
queue_free()
func _on_timed_out():
queue_free()