Viewing a Scene by itself

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By anothervenue

When I’m making scenes, I tend to position the scene origin to the center of a character, but when I run a scene on its own, it means I can’t see most of it.

Is there a workflow I’m missing, or should I be using something like a Position2D for marking the centers of scenes?

:bust_in_silhouette: Reply From: AlexTheRegent

You need to add Camera2D and check Current in its properties.

Either I am misunderstanding, or you are?

You are saying that every single scene I make, I need to attach a Camera2D to it and mark it as current? Only one camera can be current from my understanding.

I have a Camera2D in my World that works correctly. I am talking about when building a Scene by itself.

Here’s my scene in editor. The Origin is top left, but I center that on the sprite for easy centering, but running the scene (not the game), cuts off 3/4 of it.

anothervenue | 2021-01-09 19:55

I’d like to confirm that if I add a Camera2D to my player, it totally borks the level, because my game is based on a camera being in level, not on the player (sidescrolling shooter)


anothervenue | 2021-01-09 20:00

Then you can fix it by next code in singleton:

func _ready():
	if get_tree().root.find_node("name of your camera2D in scene") == null:
		var camera :=
		get_tree().root.call_deferred("add_child", camera)
		camera.current = true

AlexTheRegent | 2021-01-10 12:02