Hey everyone, I'm just wondering how I go about changing the sprite at run-time, I know it's something basic but I can't for the life of me figure it out, thanks. EDIT: Also, I'm using javascript, thanks.
Code (csharp): var newSprite : Sprite; function Start () { GetComponent(SpriteRenderer).sprite = newSprite; } --Eric
Eric5h5s response is an option or you can make sprite animations and animation states that allow you to change the sprite on the fly.
This works great! But the animations aren't playing. It only cycles through the idle regardless of whether or not you run or jump. How do you get it to play all the same animations as the previous sprite?
Add the sprite to change and other variables in a scriptable object and you can change sprites, rigidbody, collider and anything else in any object you create at RUNTIME without cluttering up the hierarchy.
Because of using an older version of Unity, and it was never Javascript, but a custom language more properly called Unityscript. --Eric