Loading a level. (Few questions)

I made a cave into my game and put a teleport trigger to get inside the cave. I realized that, if I want the game to work properly without lagg, I need to make a new scene for the cave.

When i load use Application.Loadlevel(“Cave01”);

  1. If my character has for example 70/100 health and some equipment equipped + stuff in his inventory. How do i transfer all that stuff to the cave scene.
  2. Same thing but with eg movement scripts. Can I somehow put the character related stuff to be “global” so that it saves between scenes?

Haven’t actually made the inventory scripts or health scripts yet, but I would like to know this stuff in advance, before moving forward. Thanx for the help!

1: OK, basically you can use DontDestroyOnLoad to keep your player’s stats intact

2: Global may not be quite what you want, that refers to SCOPE, but what you are reaching for is STATIC… You can make vars static (global) to keep them from resetting, but… Be AWARE, making your data members static means there is only one instance of that var across all scripts, so it retains it’s value from one script instance to another, but in the case of a player status script, that’s what you want anyway…

for example:

var score : int;  // resets on load
static var score : int;  // will retain its value between scenes (one value across all instances)