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 RGI · Jan 02, 2013 at 07:22 PM · javascriptrigidbodyaddforcesphereaddrelativeforce

A sphere moved by relativeforce is acting wierd?

Hi, I have this sphere that I am moving by this script

 var fwdspeed : float = 10;
 
 function FixedUpdate () {
 
          rigidbody.AddRelativeForce(Vector3.forward*fwdspeed);
 
 
 }

and the problem is that it moves like it should but after a while it slows down, moves forward again, then slows down again, then even moves backwards, then forwards again and so on. What is this? I tried using different physics materials and removing them, did not help.

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

2 Replies

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

Answer by clunk47 · Jan 02, 2013 at 09:16 PM

Don't use Relative Force. Relative is local direction. Just use AddForce to use world coordinates. If it's slowing down, turn down the rigidbody's drag to 0, angular drag to 0, and in script use rigidbody.MaxAngularVelocity = 100; 7 is default, 100 will make sure you have no rolling problems. Drag is what slows things down. You could also check out constantForce.force

Comment
Add comment · Show 2 · 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 RGI · Jan 02, 2013 at 10:04 PM 1
Share

O$$anonymous$$, seems like it all works as it should. I changed it to addforce and made it on Start ins$$anonymous$$d of update because it would make it go faster with every frame. then I had to set the force 100 times bigger so it would move at a normal value, is that okay? and what exactly is that maxAngularVelocity (apparently its max, not $$anonymous$$ax) the sphere would be slowing down but that max fingy makes it work just right. thank you

avatar image clunk47 · Jan 02, 2013 at 11:04 PM 1
Share

max angular velocity is how fast rigidbodies can rotate, or "roll", kinda like torque. Glad I could help :D

avatar image
1

Answer by Drakmyth · Jan 02, 2013 at 09:01 PM

I'm somewhat new to Unity and haven't really fiddled with the physics system yet, but my guess is that as the sphere rolls, it's relative coordinate system is rolling with it. Because you're applying the force relatively, it is using that constantly changing coordinate system to apply the force. Thus, each time FixedUpdate runs, your sphere will move in whichever way it's forward direction happens to be facing, which is not necessarily the same direction as it was in the editor. I think what you really want to use is rigidbody.AddForce(), as that should use the global coordinate system, which will stay constant regardless of the movement of your sphere.

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 RGI · Jan 02, 2013 at 09:08 PM 0
Share

yes, I've already tried AddForce().. It would make a different problem but clunk47 helped me solve it. Thank you.

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

10 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

Related Questions

rigidbody.AddForce to another object 2 Answers

Sphere vs Capsule collider collision resolution 0 Answers

Rigidbody.Addforce not working in Unity 5.4.1 3 Answers

AddForce and AddRelativeForce not forcing in the right directions 2 Answers

Rigid body rotation question 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