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 aLucidWorld · May 08, 2010 at 04:32 AM · gameupdatespeedfixedchoppy

even just cubes moving seems choppy

I've created several cubes on screen, one controlled by the player and the other three are computer players. This is a fight seen somewhat like the Final Fantasy turn-based games in the past. Everything was running great, I select "Build & Run" and quickly learned the difference between Update() and FixedUpdate().. movement was way too increased when running the exe as opposed to running in the builder. So, my fixed update looks something like this :

FixedUpdate() { if(move == 1) { translateY = curAttackMoveSpeed / 100; translateY = 0 + translateY; transform.Translate(0, 0, translateY); } }

  • curAttackMoveSpeed is currently set to 60.. that gives me the movement speed I want for the player when using fixed updates

The enemies are each running a copy of an enemy script that runs some code during their fixed updates as well and I have a camera rotating using the RotateAround function pointed at the player and a some movement to the side, both are very slight so the camera moves slowly.

Game ran great with Update(), found out I should be using FixedUpdate() for movements, and now it seems pretty choppy. I have 1 gig Radeon 5570 that can run Eve, Wow, you name it at highest resolutions and textures without flinching, so I know my computer can handle it. Any ideas why this would be choppy?

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 Eric5h5 · May 08, 2010 at 04:37 AM

You should not be using FixedUpdate for movements. Only for physics. The reason it's choppy is because it's not updating every frame...go back to Update.

As for the movement being different in a build vs. the editor, that's because your code is framerate-dependent. Multiply movement by Time.deltaTime; i.e., transform.Translate(Vector3.forward * moveSpeed * Time.deltaTime);.

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 aLucidWorld · May 08, 2010 at 04:51 AM 0
Share

I remember Time.deltaTime from a tutorial but it's necessity wasn't explained. Thank you so much, this was exactly what I was looking for!

avatar image aLucidWorld · May 08, 2010 at 05:16 AM 0
Share

Not sure if you'll see this or not, but I wanted to make sure.. my ray caster collision script should go in the FixedUpdate() function even though it originates from the object that is being moved in the Update() function?

avatar image Eric5h5 · May 08, 2010 at 05:20 AM 0
Share

@aLucidWorld: actually that should be in Update as well. Only things like adding physics forces (i.e., rigidbody.AddForce) would be in FixedUpdate. BTW, the docs explain deltaTime a bit more: "When you multiply with Time.deltaTime you essentially express: I want to move this object X meters per second ins$$anonymous$$d of X meters per frame."

avatar image Eric5h5 · May 08, 2010 at 05:22 AM 0
Share

Forgot to say, the system here notifies you when there are comments on your answers, so yep, I saw that. ;)

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

No one has followed this question yet.

Related Questions

What do I need to know when caching the results of a raycast every frame? 1 Answer

changing speed for 10 seconds and then return it back to its value 0 Answers

update() too fast? 2 Answers

Accelerate/Decelerate Custom Game Clock 2 Answers

getting udp package info inside unity (GlovePIE) 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