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 Vodolazz · Jun 06, 2016 at 07:15 AM · animationlinerenderer

Disabling line renderer stops animation rendering

Hi guys, i ran into the rather interesting problem while making shooting effects in my game.

This shooting effect is rather simple and is represented by a rendered line from the barrel end to target. A line renderer is enabled and disabled as a component in the script to make it blink and represent shooting. When I ran the game I saw the following: https://www.youtube.com/watch?v=m7n6kCDK8Pw

As you can see, char is frozen somewhere between animations' transitions until the next time LineRenderer component is enabled. To investigate the problem I tried to increase lasting time of the shooting effect: https://www.youtube.com/watch?v=1DLib-_PbAI

Same problem, but subroutine starts later, and character freezes later too. This breaks other animations of the Object as well.

I have workaround now. Instead of disabling the component, I just set width from zero/zero to 0.3/0.3. Everything runs smoothly: https://www.youtube.com/watch?v=J2kz4J8tWcw

But I want to understand why this happens to avoid such problems in future and expand knowledge:) If anyone has the answer, please.

P.S. Some additional info to solve the issue.

  1. My LineRenderer component and SkinnedMeshRenderer both attached to the one child object of the parent. Parent is actually a container for all model's components.

  2. Here are update and disableshootingeffect functions:

       protected override void Update()
             {
                 base.Update();
     
                 if (currentAim != null)
                 {
                     if (myShootingPrefs.IsAbleToShoot)
                     {
                         if (Vector3.Distance(transform.position, currentAim.transform.position) >= myShootingPrefs.MaxShootingDistance)
                         {
                             myShootingPrefs.IsAbleToShoot = false; myAnimController.SetBool("isAttacking", false);
                         }
                         else Shoot();
                     }
                     else
                     {
                         if (Vector3.Distance(transform.position, currentAim.transform.position) <= myShootingPrefs.ShootingStartDistance)
                         {
                             myShootingPrefs.IsAbleToShoot = true; myNavAgent.SetDestination(transform.position); myAnimController.SetBool("isAttacking", true);
                         }
                         else myNavAgent.SetDestination(currentAim.transform.position);
                     }
                 }
                      
                 if (Time.time > effectFinishTime && gunline.enabled) TurnOffShootingEffects();
             }
     
             void TurnOffShootingEffects()
             {
                 gunline.SetWidth(0f, 0f); //if we change to gunline.enabled problem with animation occurs!
             }
    
    

Huge if-else construction is used to decrease unnecessary calculations in the Update() func, because it already has a lot of instructions.

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 Lewwwer · Jul 16, 2016 at 01:57 PM 0
Share

Hello! Without the rest of the code it seems impossible to solve the problem. I'd recommend debugging all interactions with the gunline's enabled variable. So add comments after each gunline reference. What class used it for what purpose debug the changes on the variable, maybe it's a loop that causes this animation freeze.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Can the animation editor create local rotational data? 3 Answers

Adding animation clips via script 2 Answers

Get Line Renderer to restart from start everytime using coroutine. HELP?!?!?!? 1 Answer

Can I make animations snap to a frame? 1 Answer

Get line Renderer code to restart animation every time mouse is clicked 1 Answer


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