JanuaryGodotGame/januaryproject/scripts/bullet.gd

26 lines
560 B
GDScript

class_name Bullet extends Area2D
var speed = 700
signal hit
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
func _physics_process(delta: float) -> void:
position += transform.x * speed * delta
func setSpeed(value):
speed = value
func _on_body_entered(body: Node2D) -> void:
print("Bullet hit sumtin")
if not body.is_in_group("player"):
hit.emit(body)