Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411488 Posts in 69371 Topics- by 58427 Members - Latest Member: shelton786

April 24, 2024, 12:52:44 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)A fundamental question of transitioning scenes
Pages: [1]
Print
Author Topic: A fundamental question of transitioning scenes  (Read 2167 times)
kingoftheconnors
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
TonyLi
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.
Logged
Thaumaturge
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.
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic