So I have a script on my player that can control which sprite sheet SpriteRenderer uses to render my player.
ReSkinAnimation (Name of the script) spriteSheetName (public float name)
I need my script to do this:
if player is in scene = home change spriteSheetName to HomeClothes
if player is in scene = outside change spriteSheetName to OutsideClothes
Please help me correctly code this script. I’m quite new and I can’t really code with c#. Please forgive me for my stupidity
Sorry, totally misread your post. I saw ‘if player is in the scene’ and ‘if player is not in the scene’
Next question, what defines your home and outside? Is it a 3d game or 2d game?
Sorry, it’s still early in the morning but you could do something simple like this:
Scene scene = SceneManager.GetActiveScene();
if (scene.name == "home") {
// change clothes
}
else if (scene.name == "main") {
// change clothes
}
OR you can skip that logic above and just change the players clothes when you change the scenes. As you know what scene you are changing too, a script inside that scene can easily change the players clothes.
Then your change clothes function, depending on how your scene objects are set up. You will need a reference to the player or whoevers clothes you want to change. Look a look at the example in:
If your project is set up the same as the videos then you can do something like this.
ReSkinAnimation skinAnim = GameObject.Find("Player1").GetComponent<ReSkinAnimation>();
skinAnim.spriteSheetName = "blah blah blah"; // You can change the name of the sprite sheet here by changing the text