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 question was closed Dec 26, 2020 at 02:11 PM by DodgeGenesis for the following reason:

The logic works but the main issue was mostly with the use of layers in animator that causes the undesirable effects stated in this problem

avatar image
0
Question by DodgeGenesis · Dec 23, 2020 at 07:37 PM · 2d gameanimator2d animation

Can't modify the property changed by 2D animation via LateUpdate() in 1 frame

I have been digging around regarding this and all that I saw was turning off the Write Defaults and changed the modified property in LateUpdate. But apparently both seems not to work if I want to execute the property changes programmaticaly in 1 frame.

My scenario here is I want my 2D character to have an invincible mode where the player is fading in and out while still able to play the running, walking, jumping and other related animations. I also have a grow and shrink animation that also has the fading effect. So I don't want the fading effect to disappear when the player is not invincible.

So I made the invincible mode animation by sliding up and down the alpha of the sprite's color via animation recording mode. Then I made script that will only play that animation when the player is invincible and after some duration, the invincibility wears off. here is the snippet of it:

 void FixedUpdate()
         {
             if (_isInvincible)
             {
                 if (_invincibleTimer <= _maxInvincibilityTime)
                 {
                     _invincibleTimer += Time.deltaTime;
                     _animationPlayer.PlayInvincibleModeAnimation(true);
                 }
                 else
                 {
                     _animationPlayer.PlayInvincibleModeAnimation(false);
                     _isInvincible = false;
                     _invincibleTimer = 0f;
                 }
             }
       }

so as per that logic, I forced the sprite to return the alpha to 1 once _isInvincible is false in LateUpdate(). But alas, this logic affected my growth and shrink animations. Here's the code for that:

 void LateUpdate()
             {
                 if (!_isInvincible)
                 {
                     this._spriteRenderer.color = new Color(_spriteRenderer.color.r, _spriteRenderer.color.g, _spriteRenderer.color.b, 1f);
                 }
             }
 

I modified that code to only run once in 1 frame and my growth and shrink animation was back to normal but the invincible animation is affected where the player became slightly transparent after the invincibility wears off. (the alpha value is retained on which the frame of the animation is stopped to transition to another animation).

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

  • Sort: 

Follow this Question

Answers Answers and Comments

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

How to manage 2D sprite animations correctly? 0 Answers

Animation stuck on first image 0 Answers

Animator Condition Not Working 0 Answers

Shooter 2D: Character animation only runs once 1 Answer

Get Pos X and Pos Y of current playing Blend Tree motion 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