Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
2
Question by christinam · Nov 13, 2013 at 06:45 PM · blendshapes

How do I get started with Blend Shapes?

How do I get started with Blend Shapes?

Comment
Add comment · Show 1
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
avatar image remy_malin · Jul 07, 2015 at 12:14 PM 0
Share

Hello I don't have the option ‘Add Curve’ in the animation window... Do you know why ? Thanks

1 Reply

· Add your reply
  • Sort: 
avatar image
11
Best Answer

Answer by christinam · Nov 13, 2013 at 06:47 PM

Prepare Artwork

So the first thing to do would be to get your Blend Shapes setup in Maya. The following links are useful guides to getting some basic Blend Shapes ready:

http://www.artbycrunk.com/tutorial/maya/making-blendshapes-part1-beginner/?utm_campaign=Buffer&utm_content=buffer82250&utm_medium=twitter&utm_source=buffer

http://download.autodesk.com/global/docs/maya2014/en_us/index.html?url=files/Create_Deformers__Blend_Shape.htm,topicNumber=d30e358730

  • Export your selection to fbx ensuring the animation box is checked and blend Shapes under deformed models is checked.

  • Import your fbx file into Unity (assets->import new assets->[name of file].fbx).

  • Drag the asset into the hierarchy window. If you select your object in the hierarchy and look in the inspector, you will see your Blend Shapes are listed under the SkinnedMeshRenderer component. Here you can adjust the influence of the blend shape to the default shape, 0 means the blend shape has no influence and 100 means the blend shape has full influence.


    Scripting Access

It’s also possible to set the blend weights through code. Useful functions are GetBlendShapeWeight and SetBlendShapeWeight which you can read about in these doc pages:

http://docs.unity3d.com/Documentation/ScriptReference/SkinnedMeshRenderer.html

You can also check how many blend shapes a Mesh has on it by accessing the blendShapeCount variable along with other useful functions, the docs can be found here:

http://docs.unity3d.com/Documentation/ScriptReference/Mesh.html

Here is an example of code which blends a default shape into two other Blend Shapes over time when attached to a gameobject that has 3 or more blend shapes:

 //Using C#
 
 using UnityEngine;
 using System.Collections;
 
 public class BlendShapeExample : MonoBehaviour
 {
 
         int blendShapeCount;
         SkinnedMeshRenderer skinnedMeshRenderer;
         Mesh skinnedMesh;
         float blendOne = 0f;
         float blendTwo = 0f;
         float blendSpeed = 1f;
         bool blendOneFinished = false;
 
         void Awake ()
         {
                 skinnedMeshRenderer = GetComponent<SkinnedMeshRenderer> ();
                 skinnedMesh = GetComponent<SkinnedMeshRenderer> ().sharedMesh;
         }
 
         void Start ()
         {
                 blendShapeCount = skinnedMesh.blendShapeCount; 
         }
 
         void Update ()
         {
                 if (blendShapeCount > 2) {
 
                         if (blendOne < 100f) {
                                 skinnedMeshRenderer.SetBlendShapeWeight (0, blendOne);
                                 blendOne += blendSpeed;
                         } else {
                                 blendOneFinished = true;
                         }
                         
                         if (blendOneFinished == true && blendTwo < 100f) {
                                 skinnedMeshRenderer.SetBlendShapeWeight (1, blendTwo);
                                 blendTwo += blendSpeed;
                         }
 
                 }
         }
 }




Create Animations In Unity

It is also possible to use the Animation window in Unity to create a blend animation, here are the steps:

  1. Open the Animation window under Window->Animation.

  2. On the left of the window click ‘Add Curve’ and add a Blend Shape which will be under Skinned Mesh Renderer.

  3. From here you can manipulate the keyframes and Blend Weights to create the required animation. The documentation has more details about the curve editors and animation window.

  4. Once you are finished editing your animation you can click play in the editor window or the animation window to preview your animation.

Comment
Add comment · Show 4 · Share
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
avatar image meat5000 ♦ · Nov 13, 2013 at 11:07 PM 0
Share

Is this compatible with Blender's Shape$$anonymous$$eys?

avatar image christinam · Nov 18, 2013 at 10:52 AM 0
Share

Here is a code example which uses GUI sliders to adjust the different weights of three Blend Shapes:

     void OnGUI()
     {
         float horizontalSliderPos= skinned$$anonymous$$eshRenderer.GetBlendShapeWeight(0);
         float horizontalSliderPos2 = skinned$$anonymous$$eshRenderer.GetBlendShapeWeight(1);
         float horizontalSliderPos3 = skinned$$anonymous$$eshRenderer.GetBlendShapeWeight(2);
 
         horizontalSliderPos = GUI.HorizontalSlider(new Rect(25, 25, 100, 30), horizontalSliderPos, 0.0F, 100.0F);
         skinned$$anonymous$$eshRenderer.SetBlendShapeWeight(0, horizontalSliderPos);
 
         horizontalSliderPos2 = GUI.HorizontalSlider(new Rect(25, 75, 100, 30), horizontalSliderPos2, 0.0F, 100.0F);
         skinned$$anonymous$$eshRenderer.SetBlendShapeWeight(1, horizontalSliderPos2);
 
         horizontalSliderPos3 = GUI.HorizontalSlider(new Rect(25, 125, 100, 30), horizontalSliderPos3, 0.0F, 100.0F);
         skinned$$anonymous$$eshRenderer.SetBlendShapeWeight(2, horizontalSliderPos3);
 
     }
avatar image ChoChoEnzo · Feb 05, 2014 at 03:21 AM 0
Share

Hi this is awsome. I am pretty new though and i have an hard time understanding how this is working. especially line 10 and 11. is there some way we could talk about this? i would really love to learn this and the unity page is not doing it for me im afraid.

I also get this error when i try to make my own sliders: NullReferenceException sliders.OnGUI () (at Assets/sliders.cs:11)

Edit: I fixed the issue by adding your awake function. althought im still not sure what that does and why its needed. i also cannot read it in the unity reference pages. would love to understand and learn more about this topic.

avatar image christinam · Feb 05, 2014 at 10:30 AM 0
Share

Hey ChoChoEnzo! So on line 10 and 11 I am setting up my variables, in this case the type of the variables are 'Skinned$$anonymous$$eshRenderer' and '$$anonymous$$esh', they are Unity specific types just like 'GameObject'. The Awake function is only called once during the lifetime of the script instance and is mostly used for setting up variables, here is the page which explains in more detail:

http://docs.unity3d.com/Documentation/ScriptReference/$$anonymous$$onoBehaviour.Awake.html

In the Awake function I am assigning my currently null variables to be the Skinned$$anonymous$$eshRenderer and $$anonymous$$esh attached to the current object respectively, I suggest you read about the GetComponent function:

http://docs.unity3d.com/Documentation/ScriptReference/Component.GetComponent.html

I hope this answers your questions but feel free to ask more!

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

19 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Blend Shapes on mobile devices? 1 Answer

Negative blend shape values? 0 Answers

Allowing the player to draw something that turn in 2d shape with collison and solid color 1 Answer

Blending just the arms animation 1 Answer

Help with custom shader 0 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