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 reptilebeats · Apr 24, 2012 at 08:08 PM · updatefixed

fixed update predicament

hi everyone quick questin on fixed update, i asked this a while ago but have never got a direct answer. i want to know how to assign a key press to a physics movement properly.

so for instance when i press down on my keyboard my ball moves forward by torque and when i take my finger of it slows down.

now my question how to assign the key press and physics properly i read that input should be done in an update function. however i need my torque in a fixed update. what is the proper way of doing this. should i use a simple fixeddelta time inside the update or assign a new script. currently all my controls are in one control manager to optimise script updates.

im also developing for iphone so i really need to know the best way for performance please thanks....

Comment
Add comment · Show 1
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 reptilebeats · Apr 24, 2012 at 11:49 PM 0
Share

posting a commment so i might be able to get an answer

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by aldonaletto · Apr 25, 2012 at 12:18 AM

The problem in reading Input outside Update is related to functions that report button transitions (like GetKeyDown/Up, GetButtonDown/Up etc.), because these transitions are valid during the whole Update cycle where the event occurred. You will not have problems with functions that report continuous states like GetAxis, GetKey, GetButton etc. - what seems to be your case.

Comment
Add comment · Show 6 · 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 reptilebeats · Apr 25, 2012 at 01:04 AM 0
Share

im using multi touch on ios gui, however im not using on gui, im using hit test.phase in a touch loop in a fixed function.

so for one i will have

on touch add torque by 200

what i need to do is to split them up so the touch is in update and the other in fixed, if i applied the fixed delta time to the torque would that be like seperating into those catorgories..

avatar image reptilebeats · Apr 25, 2012 at 01:08 AM 0
Share

oh i havent really noticed much loss in response to the gui unless i get lag which is because i have a lot of objects not combined yet and components not cached.

avatar image aldonaletto · Apr 25, 2012 at 08:21 AM 0
Share

$$anonymous$$y bad! I haven't noticed you're developing for touch screen... Anyway, you could store your "button state" in some boolean variable and use it in FixedUpdate.
You don't have to worry about deltaTime when using AddTorque or AddForce in FixedUpdate - the torque/force is applied during the whole physics cycle, which always have the same duration (fixedDeltaTime) in the internal physics clock.

avatar image reptilebeats · Apr 25, 2012 at 12:16 PM 0
Share

i did think of doing a simple on of function, i might try it. im also trying to $$anonymous$$imise functions used though as i heard they decrease performance. i try to only have one main update function running at any given time.

i thought maybe i could just chuck it all into an update with a fixed delta time for the torque

avatar image aldonaletto · Apr 25, 2012 at 04:16 PM 0
Share

You may have a somewhat random result - from the physics engine point of view, Update occurs at very unpredictable and irregular rate, and this could cause the force/torque to be applied at random intervals if Update is slower than FixedUpdate.
On the other hand, movement is the integral of the integral of the force, what works like a filter and greatly smooths out the effects of force variations.

Show more comments

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

A node in a childnode? 1 Answer

C# UNITY_IPHONE, Still executing in update()? 1 Answer

Interpolated Fixed Timestep 2 Answers

Updating Unity 1 Answer

Failed to update unity web player. 1 Answer


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