Is it better to have the Player being instanced by a level rather than being part of it?

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


So i need a bit of advice here. Thus far i have only used the second option, e.g. having my Player being a part/node of a level from the very beginning (added through editor).
But now i´m wondering if it would be better to instance the player via the _ready callback each level. What are the pros and cons of them both?

How do you handle that, what is your approach?

PS: Talking about 2D Platformers and Top-Down Action RPGs, e.g. games with levels and a visual/controllable player character.

:bust_in_silhouette: Reply From: hilfazer

I do neither. I don’t have the player instanced on level in the editor and i also don’t instance it in level’s _ready().
Instead i instance the player from parent’s scene of the level once level is ready.
When i change levels i take player’s avatar from current level and insert it into the next level once it’s ready.

This way there’s no coupling between level and the player. It gives me great flexibility since levels do not dictate what the player node is. It may not be needed for platformers but i recommend it for games with complex player units like ARPGs you’ve mentioned.

I’m assuming “player” means player’s avatar.