Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Newby |
I have a very long script for my shotgun shoot func because i want it to fire multiple bullets in one shot so currently this is how it looks like
func shoot():
play("Shoot")
$Shoot.play()
var bullet1 = BULLET.instance()
var bullet2 = BULLET.instance()
var bullet3 = BULLET.instance()
var bullet4 = BULLET.instance()
var bullet5 = BULLET.instance()
get_parent().get_parent().get_parent().call_deferred("add_child", bullet1)
get_parent().get_parent().get_parent().call_deferred("add_child", bullet2)
get_parent().get_parent().get_parent().call_deferred("add_child", bullet3)
get_parent().get_parent().get_parent().call_deferred("add_child", bullet4)
get_parent().get_parent().get_parent().call_deferred("add_child", bullet5)
bullet1.set_position($Position2D.get_global_position())
bullet1.damage = DAMAGE
bullet1.accuracy = ACCURACY
bullet2.set_position($Position2D.get_global_position())
bullet2.damage = DAMAGE
bullet2.accuracy = ACCURACY
bullet3.set_position($Position2D.get_global_position())
bullet3.damage = DAMAGE
bullet3.accuracy = ACCURACY
bullet4.set_position($Position2D.get_global_position())
bullet4.damage = DAMAGE
bullet4.accuracy = ACCURACY
bullet5.set_position($Position2D.get_global_position())
bullet5.damage = DAMAGE
bullet5.accuracy = ACCURACY
recovering = true
AMMO -= 1
its not that pretty, is there a simplified way to spawn in multiple bullets with a shorter script?