Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by $$anonymous$$ · Sep 21, 2015 at 09:34 AM · animationcanvasspritesavatar

How to animate 2d characater Avatar (Portrait) whit dynamic changes.

I'm implementing a dialogue system in unity 5. The system shows:

  • Avatar/Portrait of the character (UI. Image)

  • Text

  • ...

Like this:

alt text

alt text

My problem is with the Avatar of the player.

At this point I manage to dynamically change the avatar depending of whom says the dialogue. I created a XML with the text and who says what. So, if in the XML Character1 has text, I will change the sprite of the UI. Image (SourceSprite) of the Canvas with the corresponding sprite (in this case the one from Character1). So far so good.

Now, I want to make pre-made animation for those sprites. For example, Charcater1 moving the lips. Character2 moving eyes and so on.

I would like to have a modular approach.

I tried to do the following:

  • In the UI.Image CharAvatar (which is part of a Canvas and all the related components) I added an Animator component.

  • I did the animation using the sequence of sprites (moving lips, for example): Sprite1, Sprite2, Sprite3. This generates an AnimationController that is attached to that instance of the Sprites that I putted in. Notice that that Image component used for the animation is not the CharAvatar Image component (of my dialogue system), because I can have X amount of different avatars. I can't attach the specific moving lips animation, for example, to that placeholder CharAvatar Image. If the dialogue changes character i would have a different animation (in a different controller, etc.)

  • In code, when a new character appears, assign to the Animator the correspondent Controller:

      myAnimator.runtimeAnimatorController = Resources.Load<RuntimeAnimatorController>("CharactersAnimations/Character1/Charcater1Controller") as RuntimeAnimatorController; //I saved them in the Resoruces folder
    
    
    

Is not working because the Controller is associated to the specific instance of the Sprite. Notice that is not the Sprite alone (is not possible to add a component to the Sprite alone). I need to create an object in Unity, them put the Sprite whit a Sprite Render component or an Image component with all the canvas components associated and then do the animation.

So, to make it work I would have to assign all that GameObject to the canvas somehow (with all the components). As you can see is not good.

Would like to ask for a better solution.

Thanks

canvas.png (7.6 kB)
canvas2.png (47.6 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

1 Person is following this question.

avatar image

Related Questions

Playing a different sprite prefab on collission. 1 Answer

Creating avatar and avatar masks for 'non-fbx' in the editor 1 Answer

Changing sprites with animations 0 Answers

Switching sprite sheets at runtime using Unityscript 0 Answers

Changing how my character looks depending on his current lifes. 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges