0 votes

In my 2D space game I'm instanciating a generated system-scene when the player-ship enters a specific area and add it to the world node. Once the player leaves this scene by moving to a specific distance I remove the scene and set the player's position to it's entering position (previously saved by a singleton).

(this way I can open and close systems from the game-world pretty easy without losing important references)

There are 2 possible outcomes:
--> when I add print(String(singleton.player_ship.global_position)) after setting it's position it works

--> when I don't add it, setting it's position to it's entering position doesn't work

This kinda confuses me a lot :/
Does anyone know why this problem might occures?

Godot version 3.2.1
in Engine by (14 points)

A print statement shouldn't affect your code. Can we see the rest of your code?

Sure :D
I might have overused singletons (GameManager,ObjectManager and SceneManager)
So when I comment out the last print statement the ship stays at it's position

func _process(delta):

if (ObjectManager.player_ship.position-GameManager.selected_system.rect_position).length() > world_length and !exit:
    print("exiting system")
    exit = true

    ObjectManager.player_ship.global_position = GameManager.ship_entering_position
    print("ship position: %s" % String(ObjectManager.player_ship.global_position))

I use exit as bool so I'm sure it only get's called once,worldlenght is just an int and SceneManager.closesystem() calls removechild(systemscene)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.