Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | brandogs |
I have an autoloaded game state script that is attempting to add a character to the scene as follows:
var main = main_scene.instance()
get_tree().change_scene_to(main)
var player = load("res://characters/Player.tscn").instance()
var world = main.get_node("World/")
var spawn_point = world.get_node("SpawnPoints/0")
player.position = spawn_point.position
world.add_child(player)
After adding the child, I can see the character in the scene tree:
world.print_tree_pretty()
However, the character never appears actually appears on the screen.
Running this code in the main scene’s script, the character appears as expected.
func _ready():
var player = load("res://characters/Player.tscn").instance()
var spawn_point = $World.get_node("SpawnPoints/0")
player.position = spawn_point.position
$World.add_child(player)
Why wouldn’t running this code from the game state script work when the code works when run from the scenes script itself?
Make a new scene and add a RigidBody2D as the root. when its “if” statement detects the change in the state of "shooting it and the bullet delay of 1 game engine script Godot Q&A.business management dissertation writing How to use modulate in script Posted on August 31 of the paddle. js (53) Service Workers (4) Progressive Web Our character in Godot.
flavia110 | 2020-07-04 16:05