Files
FebruaryGame/februarygodotgame/scripts/bullet.gd
T

22 lines
469 B
GDScript
Raw Normal View History

2025-03-03 20:40:27 -05:00
class_name Bullet extends Area2D
@onready var bulletGraphic: Sprite2D = $Sprite2D
2025-03-03 20:40:27 -05:00
var speed = 750
signal hit(bullet, body)
func setSpeed(value):
speed = value
if speed<0:
bulletGraphic.flip_h = true
if speed>0:
bulletGraphic.flip_h = false
2025-03-03 20:40:27 -05:00
#animation
func _physics_process(delta: float) -> void:
position += transform.x * speed * delta
func _on_body_entered(body: Node2D) -> void:
print ("bullet collision")
if not body is Player:
hit.emit(self, body)