Search Unity

Game Manager to store textures and player model

Discussion in 'Scripting' started by chainsawpenguin, Feb 11, 2016.

  1. chainsawpenguin

    chainsawpenguin

    Joined:
    Sep 28, 2014
    Posts:
    107
    Good evening, team! I'm trying to write a Game Manager script to keep track of several variables, and I've quite succeeded in keeping track of a player's stats (SIWDCCh, eg) from scene to scene. Hooray!

    However, I'm stumbling a little bit in how to keep track of the player character's model and texture.

    For an example, my player character enters a new scene, and drinks a Potion of Wolfingness. Through my script, I swap out the human player model with a model of a werewolf, and when he goes outside, into the previous scene, he should still be the werewolf model.

    Later, he finds a potion of Bluegreen fur, turning his dark fur bluegreen, which is just a swap out of a texture. Again, we'd need this to persist from scene to scene.

    I feel like there's something SIMPLE that I'm missing here...

    Does anyone have any guidance/thoughts/examples of this sort of thing?

    Thanks in advance for any nudge in the right direction!

    ~~ ChainsawPenguin ~~
     
  2. pixpusher2

    pixpusher2

    Joined:
    Oct 30, 2013
    Posts:
    121
    Use some internal variables to keep track of the player's status (bool isWerewolf, Color furColor, etc.). Check for them at the beginning of each scene and reapply the effects.

    Code (CSharp):
    1. //pseudo code
    2.  
    3. void Start()
    4. {
    5.     if (player.isWerewolf == true)
    6.         // load werewolf model
    7.     else
    8.         // load human model
    9. }
     
  3. chainsawpenguin

    chainsawpenguin

    Joined:
    Sep 28, 2014
    Posts:
    107
    Ohhhhhh... cool! I keep a variable (bool, int, whatever) in the GameManager, then in the start block I call that value to see if he's a werewolf or whatever, but there's no requirement to keep the actual MODEL or TEXTURE in the GM!

    Thanks!

    ~~ ChainsawPenguin ~~