So basically, i want to spawn multiple instances of a same scene with different rotations and locations. on the same processing tick. I tried multiple things but none worked like . Any help would be greatly appreciated.
This is my player code
extends KinematicBody2D
var bullet = preload("res://bullet/bullet.tscn")
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
var speed = 250
# Called when the node enters the scene tree for the first time.
func _ready():
set_physics_process(true)
set_process(true)
func _physics_process(delta):
if Input.is_action_pressed("ui_left"):
move_and_collide(Vector2(-speed*delta,0))
if Input.is_action_pressed("ui_right"):
move_and_collide(Vector2(speed*delta,0))
var bulletInstance = bullet.instance()
bulletInstance.position=Vector2(position.x,position.y)
get_tree().get_root().add_child(bulletInstance)
bulletInstance.position=Vector2(position.x+20,position.y)
get_tree().get_root().add_child(bulletInstance)
#func _process(delta):
#if Input.is_action_just_pressed("fire"):
#var bulletInstance = bullet.instance()
#bulletInstance.position=Vector2(position.x,position.y-20)
#get_tree().get_root().add_child(bulletInstance)
and this my bullet code
extends KinematicBody2D
var speed = 500
# Called when the node enters the scene tree for the first time.
func _ready():
set_physics_process(true)
func _physics_process(delta):
move_and_collide(Vector2(0,-speed*delta))
if get_position().y>ProjectSettings.get_setting("display/window/size/height")-10 or get_position().y<-10:
queue_free()