JulyGameTTL/Scripts/bullet.gd

27 lines
539 B
GDScript3
Raw Normal View History

2025-08-12 01:08:52 +00:00
class_name Bullet extends Area2D
2025-08-26 01:11:19 +00:00
@onready var bulletgraphic = $bulletgraphic
2025-08-12 01:08:52 +00:00
var speed:float = 700
signal bulletDamageSignal(body, bullet)
func setSpeed(value:float):
speed = value
2025-08-26 01:11:19 +00:00
if value<0:
bulletgraphic.flip_h = true
if value<0:
bulletgraphic.flip_h = false
2025-08-12 01:08:52 +00:00
func _physics_process(delta:float) -> void:
position += transform.x * speed * delta
func _on_body_entered(body: Node2D) -> void:
print("Bullet hitting")
if body.is_in_group("shootables"):
print("This is shootable")
bulletDamageSignal.emit(body, self)