How do you independently test a scene that references other scenes
Asked Answered
N

3

0

I have a scene with code that is meant to affect another scene, so I can't test the first scene "Disc" by itself. I've been reading about "singletons" and "autoload", and heard that you shouldn't use "get_node()" because it's brittle and my code will break, but it's a little confusing.

I just thought I'd see if anyone could help me understand better while I try to read more about it and experiment with it. This is the code for my "Disc" that is supposed to make the "Player" rotate with it, but they are two different scenes, so like I said, if "Player" isn't present in the tree, it will crash.

Novanovaculite answered 8/1 at 1:15 Comment(0)
F
0

If you want that code to run when the Player node isn't available, you could replace get_node() with get_node_or_null(), and check is_instance_valid(player) before calling player.rotate().

Featherweight answered 8/1 at 2:33 Comment(0)
C
0

Novanovaculite If a component (scene) is built to interact with the player then there's no sense in testing it without the player.

Cagle answered 8/1 at 2:43 Comment(0)
N
0

Thank you for the advice.

Novanovaculite answered 8/1 at 18:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.