JulyGame/scripts/bullet.gd

24 lines
548 B
GDScript3
Raw Normal View History

class_name Bullet extends Area2D
@onready var bullet_graphic: Sprite2D = $BulletGraphic
var speed:float = 700
signal bulletDamageSignal(body, bullet)
func setSpeed(value:float):
speed = value
if value<0:
bullet_graphic.flip_h = true
if value>0:
bullet_graphic.flip_h = false
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)