• 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
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. T$$anonymous$$s is a fight seen somewhat like the Final Fantasy turn-based games in the past. Everyt$$anonymous$$ng 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 somet$$anonymous$$ng like t$$anonymous$$s :

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 $$anonymous$$ghest resolutions and textures without flinc$$anonymous$$ng, so I know my computer can handle it. Any ideas why t$$anonymous$$s would be choppy?

Comment

People who like this

0 Show 0
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
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
aLucidWorld
KHopcraft

People who like this

2 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 instead 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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

getting udp package info inside unity (GlovePIE) 0 Answers

Major Error - Unity ninja's required !!! - Scene + Script"freezes" 2 Answers

How do I increase the speed of a sphere on collision ,How do I make an object move faster when a force is applied 1 Answer

Building updater 1 Answer

How to round a number? 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