Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Ceo-Potato |
I’m trying to make an asteroids clone and when I try to use the laser it crashes
Laser_weapon.gd
extends Node
var laser_red := load("res://Scenes/common/Lasers/laser_red.tscn")
var laser_blue = load("res://Scenes/common/Lasers/laser_blue.tscn")
func shoot():
var laser = laser_red.instance()
laser.global_position = self.global_position
get_node("res://Scenes/World/Level.tscn").add_child(laser)
Here I call the “shoot” function
ignore Control_mode
func _unhandled_key_input(event: InputEventKey) -> void:
if Control_mode == 1:
if (event.is_action_pressed("Space")):
$Laser_weapon.shoot()
maybe problem is here :
get_node(“res://Scenes/World/Level.tscn”).add_child(laser)
onready var current_scene = get-tree().current-scene
current-scene.add-child(laser)
ramazan | 2022-01-05 11:56