Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

Advanced search

1404717 Posts in 68420 Topics- by 62073 Members - Latest Member: HWinsen

February 05, 2023, 03:01:48 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)A fundamental question of transitioning scenes
Pages: [1]
Author Topic: A fundamental question of transitioning scenes  (Read 1914 times)
Level 0

View Profile
« on: April 10, 2021, 05:32:45 PM »

In Unity and similar engines, you go from one level to another, and have to destroy the old to make room for the new. But what about the player?  Blink

Is it better to have a NEW player instance, possibly already placed in the new level, so you can clearly see where the player appears, or is it better to drag the player from the original scene and place them in the new one?
« Last Edit: April 10, 2021, 05:44:12 PM by kingoftheconnors » Logged
Level 0

View Profile
« Reply #1 on: April 11, 2021, 11:19:09 AM »

It very much depends on the game, but I generally prefer to have a new player instance in each scene. It's easier to playtest individual scenes, and you get a clean player instead of potentially carrying bad baggage from the previous scene.

Many games record state information in the old scene before leaving. This way they can restore that state when the player returns to the old scene. You can also apply some of this state info (e.g., the player's health and inventory) to the new player instance in the newly-loaded scene.
Level 10

View Profile WWW
« Reply #2 on: April 12, 2021, 04:18:22 AM »

Adding to that answer of "it depends", as I recall in one of my own projects the short answer might be given as: "both". That is, I have two player-classes:
  • A "player core" that persists between levels, and which contains things intended to carry between them, like inventory items
  • And a "level-player" that is created and destroyed with the level, and which carries the "player-core" within it.

Pages: [1]
Jump to:  

Theme orange-lt created by panic