How to load multiple sprites at runtime from List?
I have an animator switching blocks soon as the player hits them as an checkpoint. I am restarting the scene, if the player dies and spawning it to the checkpoint platform, thus I want to keep the checkpoint platform lit while the player has lives left. I am trying to do this by two Lists and checking the index, if its a match then change the sprite of the block in the start() method. Here's the code:
public List Blocks;
public List BlocksLitSprite;
void ChangeBlocksToLit() {
for (int i = 0; i < Blocks.Count; i++) {
if (Blocks.IndexOf (Blocks [i]) == BlocksLitSprite.IndexOf (BlocksLitSprite [i])) {
Blocks [i].GetComponent<SpriteRenderer> ().sprite = BlocksLitSprite[i];
}
}
}
For some reason it's not changing the sprites. Any suggestions? Thanks!
Comment
Answer by lingoded · Jun 09, 2016 at 01:49 PM
Solved! Just used Any State from the Mecanim and added a bool to check it, rather than trying to script it. Lol. Just don't like to use the animations.