- Home /
Dragging a sprite into an animation not working
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.
I would really appreciate if someone could update me on this. Is this a bug? Do I need to hold down a special key? Surely someone else has run into this problem...
If you could provide some screenshots of where exactly you're dragging the sprite, your animation and of what your protagonists setup is. Hopefully it will be easier to help you, it's hard to understand exactly what you're doing just though text :)
" I drag in the appropriate sprite, the sprite of the character jumping, and the Animator somehow magically creates a protagonist->sprite property, ins$$anonymous$$d of just changing the body->sprite property." What does this mean? Where are you dragging in this sprite? And I'm assu$$anonymous$$g it is a 1 sprite animation?
Answer by Gandalf_The_Black · Oct 10, 2017 at 05:50 PM
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.
O$$anonymous$$EGALUL, THATS IT THAN$$anonymous$$ YOU!
But I feel there is a problem in doing that like in my case. I hade to create a new animation by clicking on create new clip to solve this issue after selecting the player from scene view
Answer by Fohristiwhirl · Sep 02, 2014 at 08:20 PM
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.
Answer by danrayson · Oct 03, 2018 at 08:37 PM
Late also, but I just realised that it had to be an actual GameObject, not just a Prefab!