Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 PersianKiller · Jul 25, 2017 at 03:23 PM · animatorupdatefixedupdateclimblateupdate

Climb animation in Update or FixedUpdate or LateUpdate?,

alt textIt's my code.

public bool PlayerCanClimbTheLadder; public Animator animator;

 public void ClimbAnimation(){

     if (PlayerCanClimbTheLadder && Input.GetKey (KeyCode.W)) {

         animator.SetBool ("Ladder",true);
         GetComponent<Rigidbody2D> ().isKinematic = true;
         transform.Translate (new Vector2 (0, 2 * Time.deltaTime));

     } 

} Is there any difference If I use this code in update or fixedUpdate or lateUpdate ?

,

bb.png (140.4 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

1 Reply

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

Answer by SohailBukhari · Jul 26, 2017 at 06:21 AM

You should check that in LateUpdate that occurs after the internal animation update in each loop.

Input should be in Update() so that there is no chance of having a frame in which you miss the player input.

FixedUpdate used where we need to apply continuous forces. Physics calculations should be in FixedUpdate(), so that they are consistent and synchronized with the global physics timestep of the game.

Comment
Add comment · Show 12 · 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 PersianKiller · Jul 26, 2017 at 07:42 AM 0
Share

what about transform.Translate (new Vector2 (0, 2 * Time.deltaTime));?

I think if this code checks in LateUpdate or FixedUpdate the Result might be difference .???

How can I get inputs in update and place animations in LateUpdate and put physics in FixedUpdatE????

avatar image kalanadis PersianKiller · Jul 26, 2017 at 08:17 AM 0
Share

the result is the same if you use

 transform.Translate (new Vector2 (0, 2 * Time.deltaTime));

inside FixedUpdate(), LateUpdate() or Update(). in unity manual it says

When called from inside $$anonymous$$onoBehaviour's FixedUpdate, returns the fixed framerate delta time.

if you want to update the movement in FixedUpdate() you can keep a separate variable in your script to store the state of your animation. In FixedUpdate() you can check that state variable and do the movement

avatar image PersianKiller kalanadis · Jul 26, 2017 at 08:40 AM 0
Share

dude I made a test and realized that if you use transform.Translate in update or FixedUpdate the result is definitely different.

I made a time-=time.FixedDeltaTime;//

then put transform.Translate in update and then in FixedUpdate. after 5 seconds y position in Update was between 20and 22, but when I used that in FixedUpdate and everyTime it returned 21.5.

the problem is that I don't know how to get inputs in Update and then move my character in FixedUpdate and place animations in LateUpdate

Show more comments
Show more comments
avatar image PersianKiller · Jul 26, 2017 at 11:07 AM 0
Share

hmmm thanks man.

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

78 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

Related Questions

how to achieve a LateFixedUpdate effect 5 Answers

What's the execution order of Updates of different objects? 1 Answer

Should we check animation condition in Update or FixedUpdatE? 3 Answers

Coroutines vs Update/FixedUpdate/LateUpdate 2 Answers

Should terrain detail data be set on update, fixedupdate, lateupdate or coroutines? 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