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
1
Question by santodiego · Feb 07, 2015 at 09:10 PM · forcemagnetic

A Force perpendicular to the Velocity isn't working

I want to apply a force perpendicular to the velocity of the object. (I'm simulating a magnetic field exerting a force on a charge). My code looks like this:

     function FixedUpdate () {
         this.rigidbody.AddForce(Vector3.Cross(this.rigidbody.velocity, bField));
     }

The cross product makes sure the force is perpendicular to the velocity and the bField. I set bField in the Z direction and initial velocity were in the Y direction. If it were working optimally, the direction of the velocity would change but the magnitude of the velocity would stay constant, the object would move in a circle of constant radius in the XY plane. However the object is speeding up, meaning that the force is not exactly perpendicular (even though the Vector3.Cross gives a perpendicular force vector).

Any thoughts on how I can keep the Magnitude of the Velocity constant? thanks

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
0

Answer by Owen-Reynolds · Feb 07, 2015 at 11:07 PM

Sounds like the usual discrete steps simulation problem. Like the fundamental theorem of calculus, physics simulations are just breaking a continuous process into small steps. If the steps are small enough, you get very little error. But you're still simulating a curve using a series of tiny straight lines, so you will get wrong numbers.

Standard solution is to reduce the physics timestep, from the standard 0.02 seconds.

That will just give smaller errors, small enough for most people. But I suspect if you let it orbit a few times, it will very slowly grow. If you aren't bouncing and spinning crazily, you don't really need the physics system. If you can get the continuous equations for whatever your system is, can just use those to compute the position each frame.

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 santodiego · Feb 08, 2015 at 01:51 AM 0
Share

Shrinking the timestep behaves as you predicted. It looks better but still slowly creeps outward. I can always take drastic measures and adjust the components of the velocity perpendicular to the magnetic field. thanks.

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

2 People are following this question.

avatar image avatar image

Related Questions

Force perpendicular to motion of Object isn't working. 0 Answers

Applying Force Once Triggered 0 Answers

Move GameObject with Swipe and when Swipe Ended Stop Gameobject Slowly 1 Answer

Adjust movement while rotating rigidbody 1 Answer

Rigidbody2D Force Problem 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