I am modifying the 2D sidescroller template and I am having a problem. My main character is an object named protagonist. INSIDE this is another gameobject called body. protagonist does not have a sprite renderer, but body does. I want to modify an animation. So I pick an animation, let’s say, “Jump”. I go to the animator timeline and select that the body sprite renderer sprite needs to be changed. I drag in the appropriate sprite, the sprite of the character jumping, and the Animator somehow magically creates a protagonist->sprite property, instead of just changing the body->sprite property. I don’t understand this. It literally creates a sprite renderer on the protagonist when all I want to do is change the sprite of the sprite renderer on the body. I have no idea how I am supposed to do this. Please help me because this is driving me insane. Thank you so much for your help.
Hey, I’m over 3 years late, but nevermind. I was really confused for ages over this. Then I realised that all I had to do was drag it to the column on the left side in default view. Huh.
Does the child GO have both a sprite renderer and animator component? also the animation clip that you created in the animation window is that hooked up to the animation controller?
You can’t drag animation clips onto a game object. The sprite renderer displays only one sprite at a time, the animation changes the sprite the renderer is displaying in the correct order at a steady rate to simulate movement.
I created a test project. Created two empty GO’s called one protagonist and one sprite. Made sprite a child of Protagonist. Added a sprite renderer and animator component to sprite. Dragged a demo sprite onto the Sprite field of the sprite renderer. By this point I had a static sprite appearing in the scene view.
Next I created an animation clip and animation controller. I assigned the animation controller to the controller field of the animator component on the sprite GO. I set the default state of animation in the mechanim animator window to the animation I made. Now when i press play the sprite animates correctly.
Late also, but I just realised that it had to be an actual GameObject, not just a Prefab!