i wana make it so the player can oly shoot in the direction they are looking this is my curent shooting code extends Node2D
var bullet_scenes = {
0: preload("res://ice_bullet.tscn"),
1: preload("res://thunder_bullet.tscn"),
2: preload("res://flame_bullet.tscn")
}
func fire():
if not PlayerStats.has_ammo():
print("No ammo!")
return
var bullet_scene = bullet_scenes.get(PlayerStats.current_bullet)
if bullet_scene == null:
print("Bullet scene not found!")
return
var bullet = bullet_scene.instantiate()
var mouse_pos = get_global_mouse_position()
var direction = (mouse_pos - global_position).normalized()
var angle = direction.angle()
bullet.dir = angle
bullet.pos = global_position
bullet.rot = angle
bullet.dmg = PlayerStats.bullet_dmg
get_parent().add_child(bullet)
PlayerStats.use_ammo()
func _process(delta):
if Input.is_action_just_pressed("shoot"):
fire()