18 lines
353 B
GDScript
18 lines
353 B
GDScript
class_name Bullet extends Area2D
|
|
|
|
var speed = 750
|
|
# did I hit anyone?
|
|
signal hit(bullet, body)
|
|
|
|
func setSpeed(speedValue):
|
|
speed = speedValue
|
|
|
|
func _physics_process(delta):
|
|
position += transform.x * speed * delta
|
|
|
|
|
|
func _on_body_entered(body: Node2D) -> void:
|
|
print("Bullet hit something")
|
|
if not body.is_in_group("player"):
|
|
hit.emit(self, body)
|