Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 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
2
Question by xikky · Feb 27, 2013 at 06:38 PM · rigidbodyperformanceaddforceoncollisionenter

Adding force on collision performance question.

I need to add force to both objects when these hit. Would it be a better practice to trigger a boolean value OnCollisionEnter, which will trigger a function inside the Fixed Update (and here I put add force code)? Rather then applying force inside the OnCollisionEnter?

Same thing I'm doing for inputs which will incur and AddForce. I capture an input in an Update (Example: Input.GetKey("left")) which triggers a boolean and in turn triggers the Addforce function inside FixedUpdate

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
1
Best Answer

Answer by AndrewGrayGames · Feb 27, 2013 at 07:18 PM

As far as performance is concerned, I highly doubt it should be an issue for a small number of objects - very large numbers of objects would start to tax either the CPU, or GPU that is handling physics calculations. As far as I've observed, Unity handles physics calculations pretty efficiently.

What does concern me, is if you should need to do it this way at all, as you're using physics.

If you're implementing some type of friction on each object, yes having your collision objects set a boolean which tells the FixedUpdate method to start applying friction every frame could work, until the force on the object falls to a certain threshold, where forces on the object are set to zero and the flag cleared.

If you're operating in a frictionless environment (e.g. space), you can get away with just setting the force on-collision. Presumably, your control system will apply forces and torque to the player's object to allow them control, as your AI will do the same to control your CPU-controlled entities.

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 xikky · Feb 28, 2013 at 06:52 AM 0
Share

Thanks Asvarduil. I need to apply friction on my objects, so I'm sticking to my method.

I didn't understand clearly the last part of your third parag. The part of providing a threshold for forces on an object.

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

11 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

Related Questions

Rigidbody2D won't apply force after collision 0 Answers

When to use OnCollisionEnter and OnTriggerStay and how to use rigidbody.AddForce 1 Answer

Rigidbody not calling OnCollisionEnter 1 Answer

RigidBody2D - AddForce - KnockBack Effect. 1 Answer

AddForce mechanism ? 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