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 /
avatar image
0
Question by Dogg · Aug 19, 2014 at 01:54 AM · updatetimejumppause

Is It Bad To Have Your Jump In Update()?

Is it bad to have your jump in the Update() method/function? Currently I do, and everything seems to work correctly, but the reason why I'm asking is because I'm curious and I was wondering if there is any performance issues with that. Also, I recently changed my jump to if (grounded && Input.GetMouseButtonDown(0)) {, and it works fine, but when I press the pause button the Player obviously jumps a little, but when I press the resume button the Player goes flying in the air, hits the top wall, and dies. Why is that? Does the Update have anything to do with it? Since my pause button uses Time.timeScale the Update is not affected so that's why I ask this question.

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

3 Replies

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

Answer by DBar · Aug 19, 2014 at 02:22 AM

It is just a matter of experimentation of Update and FixedUpdate because it dependes in a lot of factors. It is relative to the amount of code and the Unity Settings in Time and Physx. If you are aiming to mobile then just build and take notes of your results.

About the Time.timeScale not affecting Update it is wrong. Time.timeScale affects EVERYTHING in the Unity Universe.

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 Dogg · Aug 19, 2014 at 03:11 AM 0
Share

Thank you, and sorry I didn't know it affected everything. I read many post and a lot of times they said that it didn't affect the Update.

avatar image Kiwasi · Aug 19, 2014 at 03:35 AM 2
Share

This answer is technically incorrect.

  • Update will still run while Time.timeScale is 0

  • Time.deltaTime will return 0, so anything that relies on this value will stop

  • FixedUpdate will not run if Time.timeScale is 0

There is no need for experimentation on Update versus FixedUpdate. The docs are quite clear on what each function does. And a little bit of logic will let you know what belongs in each method.

avatar image Kiwasi · Aug 19, 2014 at 03:43 AM 0
Share

Here is a link to the documentation on Time.timeScale

avatar image DBar · Aug 19, 2014 at 04:39 AM 0
Share

Well, well. Im green answering i guess. Let's see. If the PLAYER is moved by a character controller, forces with AddForce or just the transform directly or with translate the ecuation is NOT so simple and of course, the player is affected by the time.TimeScale and then, time affects everything RELATED to the player, what the players see and does. It is not technically incorrect to say that time affects everything. It does so, you are wrong but i see your point.

About not needing experimentation, well, ask that to the guys in Black $$anonymous$$esa ;)

But, your answer completes $$anonymous$$e so, thanks for the help.

avatar image
0

Answer by Kiwasi · Aug 19, 2014 at 02:14 AM

A lot depends on how you jump. General rules

  • Everything that uses physics or RigidBody should go in FixedUpdate

  • Everything in update gets called every frame, so should be as efficient as possible

  • Anything that needs to be affected by timescale should use Time.deltaTime

Comment
Add comment · Show 3 · 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 Dogg · Aug 19, 2014 at 03:11 AM 0
Share

I see, okay then thanks Bored.

avatar image DBar · Aug 19, 2014 at 04:48 AM 0
Share

This is wrong. It depends on cpu miliseconds and feeling of the animation. It is not the same to use physx with a rigidbody affected by gravity or a rigidbody without gravity.

Come on.

avatar image Kiwasi · Aug 19, 2014 at 07:09 AM 0
Share

@DBar - I'm not sure what you are specifically calling out as wrong here. I provided a pretty generic piece of advice to a pretty generic question.

But if you want the detailed answer:

Physics in Unity runs at a set frame rate. FixedUpdate is called just before the physics engine updates. Hence any changes that affect the physics engine need to run in FixedUpdate.

Update runs as fast as it can and is called just before the visual update cycle. Game logic and input controls normally go here. Anything that needs updating at a high frequency.

Back to the OP, if jump is a physical effect and uses force then the jump should be executed in FixedUpdate. On the other hand if jump is a visual effect and just moves the transform around then it should be in Update. Either way input should be captured in Update.

This is all independent of hardware performance or any aesthetic considerations. I'm not sure where your knowledge of Unity comes from, but I suggest getting a lot more time on the tools before you start calling me out on my answers. The most common reason for jump coding to fail (jumping twice as high, or missing jump inputs) is because the logic is in the wrong method.

avatar image
0

Answer by TheXyon · Aug 19, 2014 at 02:22 AM

I'm no expert (in fact i'm quite green behind the ears) but things like "Jump" should be in the FixedUpdate function.

Comment
Add comment · Show 1 · 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 Dogg · Aug 19, 2014 at 03:11 AM 0
Share

Okay thanks.

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

25 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

Related Questions

Pause Menu Text Not Rendering 0 Answers

pause timer or player using Time.timeScale 1 Answer

Pause Game When Function Is Enabled? 3 Answers

How to pause a game? 2 Answers

Jump, fall, and after determined time it's able to jump again. 2 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