Why won't my bullet move!?

Godot Version

4.2.2.

Question

lightning_2.1.tscn is my bullet.

So far it collides with my enemies, damages them, plays impact/death animations, and then deletes itself. The only thing I can’t get working is the lightning_2.1 to move. The gun follows my mouse and the bullets should be moving forward.

Here is lightning_2.1 script

extends AnimatedSprite2D
 
var bullet_impact_effect = preload("res://scenes/bullet_impact_effect.tscn")
 
var speed : int = 600
var direction : int
var damage_amount : int = 1
 
func _physics_process(delta):
	move_local_x(direction * speed * delta)
 
 
func _on_timer_timeout():
	queue_free()
 
 
func _on_hitbox_area_entered(area):
	print("Bullet area entered")
	bullet_impact()
 
 
func _on_hitbox_body_entered(body):
	print("Bullet body entered")
	bullet_impact()
 
 
func get_damage_amount() -> int:
	return damage_amount
 
func bullet_impact():
	var bullet_impact_effect_instance = bullet_impact_effect.instantiate() as Node2D
	bullet_impact_effect_instance.global_position = global_position
	get_parent().add_child(bullet_impact_effect_instance)
	queue_free()

Let me know if you need to see any other scripts or anything!

I believe the tutorial I was following is for side scrolling game so it seems he has movement of the bullet only along the x axis but I need it to move forward in any direction. It’s already leaving the gun the way I want it to. I just need it to travel forward instead of freezing as soon as appearing.

Your direction variable is initialized to zero.

1 Like

Could you explain a little bit more in detail? is it because var direction : int? What would I make the direction variable as?

Yes. Make it non-zero. (0 * speed * delta) is zero.

1 Like

My guy you are a legend! I don’t know why this had me slipped up for so long compared to everything else I managed to fix! Thank you!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.