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 mavii_ege · Dec 12, 2014 at 02:05 AM · rigidbodyaddforcedifferent

rigidbody addforce behaves different every time

i am using addforce to throw objects but object travel distance changes every time sometimes it goes 5 units sometimes 1 not sure why

Comment
Add comment · Show 11
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 VesuvianPrime · Dec 11, 2014 at 10:32 PM 0
Share

Can you provide any code to demonstrate/reproduce the issue?

avatar image mavii_ege · Dec 11, 2014 at 10:51 PM 0
Share

i am using this line to add force objectWorkedOn.GetComponent().AddForce(transform.forward * Time.deltaTime * throwPower); and i have rigidbody with default values on my object, my script is pretty long so i cant reproduce it easily, time.deltatime might be the issue im not sure i am also changing angular velocity while adding force

avatar image VesuvianPrime · Dec 12, 2014 at 02:25 AM 1
Share

Huh, just read the docs you linked, I didn't realize it behaved differently in the FixedUpdate loop. $$anonymous$$y apologies.

In that case I'd want to debug to confirm that the result of the force calculation is the same every time.

avatar image NicRule · Dec 12, 2014 at 02:35 AM 3
Share

I would recommend using: objectWorkedOn.rigidbody.AddForce(transform.forward * throwPower, Force$$anonymous$$ode.Impulse); Force$$anonymous$$ode sets how the force is applied. Impulse is for forces applied for one frame. The default (not declaring a Force$$anonymous$$ode) is usually for forces applied over time. If you are using $$anonymous$$onodevelop when you type Force$$anonymous$$ode. you can read all the options.

avatar image MrSoad · Dec 12, 2014 at 02:37 AM 1
Share

Yep that too @NicRule :)

Here is the docs link for the Force$$anonymous$$odes :

http://docs.unity3d.com/ScriptReference/Force$$anonymous$$ode.html

Show more comments

2 Replies

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

Answer by mavii_ege · Dec 12, 2014 at 10:13 AM

i fixed the problem by using fixeldelta time im calling my function from update but its only called when key pressed and its called once so you get one inconsistent value from time.deltatime but fixeddeltatime gives a constant value so bomb power same everytime, thanks for the suggestions

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 VesuvianPrime · Dec 12, 2014 at 02:49 PM 2
Share

That's not really a good fix, all you're doing is multiplying the force by something like 0.02.

I'd suggest using @NicRule's suggestion.

avatar image
0

Answer by vfxjex · Jul 20, 2016 at 09:33 AM

you don't need to multiply it with "Time.deltaTime". PhysX has already added this into rigidbody and multiplaying it just making it back to be unstable. It is like having this (Time.deltaTime * Time.deltaTime).

also if dealing with single frame use rb.AddForce (x,y,z, ForceMode.Impulse) as mentioned also by @NicRule.

but if you really want to have more fixed value for jumping use rb.velocity = new Vector3(x,y,z);

Comment
Add comment · 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

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

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Rigidbody-based spaceship? 1 Answer

Jumping with rigid body3d 1 Answer

rolling ball movement on different axis 0 Answers

push crate - works in editor, not on device 2 Answers

Rotation problem with spawning bullet 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