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 D-Coy · Aug 13, 2017 at 11:14 AM · coroutinelerpblendshapesyield waitforseconds

Lerping blinks

Hi, I have a problem thats been bugging me for a while. Im trying to build some natural facial animation scripts and having trouble with timing. Currently, in this script, I have the character blinking using loops, where I can control the speed, but its very robotic. I would like to be able to lerp the motion to ease in/out the anim but if I try inserting blinkLerp it doesnt finish the motion due to yield not working the way I want or it jumps to open of closed.

As a whole, Id love to find a better way to do this, Lerping at random intervals, but have had little success in achieving it. Any help would be appreciated. Thanks

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class blendCTRL : MonoBehaviour
 {
     int blinkDown = 10;
     int counter = 100;
     bool blinker=false;
     int blendSpeed = 50;
     public int lidHeightMax = 10;
     private SkinnedMeshRenderer skinMeshRenderer;
 
     void Start()
     {
         StartCoroutine(RandomWait());
         skinMeshRenderer = GetComponent<SkinnedMeshRenderer>();
     }
 
     IEnumerator RandomWait()
     {
         while (true)
         {
             yield return new WaitForSeconds(Random.Range(0, 5));
             blinker = true;
         }
     }
 
     void Update()
     {
         skinMeshRenderer.SetBlendShapeWeight(0, blinkDown);
 
         if (blinker == true & blinkDown < counter)
         {
             blinkDown = blinkDown + 10;
         }
         else if (blinkDown == 100)
         {
             while (blinkDown > lidHeightMax)
             {
                 blinkDown--;
             }
             blinker = false;
         }
     }
     void blinkLerp()
     {
         skinMeshRenderer.SetBlendShapeWeight(0, Mathf.Lerp(0, 100, blendSpeed * Time.deltaTime));
     }
 }
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by D-Coy · Sep 11, 2017 at 08:49 PM

Still looking for help on this. Triggering a ping ponging, lerped blend at random intervals. thanks

Comment
Add comment · 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

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

71 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 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 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 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

[WORKAROUND] How to time pause in update (yield) 1 Answer

Yield Never Works 4 Answers

Cannot duplicate Coroutines and Yield Instruction in the Unity Manual... Is the manual WRONG? 4 Answers

object's children not moving with it when using a Lerp-ing coroutine 0 Answers

bounce player back to position while jumping 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