GodotCourse/week2/updated_files/scripts/bullet.gd

18 lines
316 B
GDScript

class_name Bullet extends Area2D
var speed = 750
signal hit(bullet, body)
func setSpeed(speedVal):
speed = speedVal
func _physics_process(delta):
position += transform.x * speed * delta
func _on_body_entered(body):
print("bullet hit something")
if not body.is_in_group("player"):
hit.emit(self, body)