Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6716257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:42:42+00:00 2026-05-26T08:42:42+00:00

So i have some bodies(which i can create more and more at runtime), and

  • 0

So i have some bodies(which i can create more and more at runtime), and i need them to be magnetized to the screen center. Let it be a (480/2 / WORLD_SCALE, 320/2 / WORLD_SCALE) in the world space. I am new to box2d so maybe there is an easy way to achieve this, but i am trying to do it as following:

  1. I subtract each bodie’s position and screen center position – to get a direction to where i need to move my body to.
  2. Normalize the direction vector(which i’ve found in p.1)
  3. Multiply this normalized vector to my gravity power value
  4. Add the vector(that i’ve got in the p. 3) to the current bodie’s speed

So after that i get what i want – bodies do magnetize to the screen center, i also add some frictions, and dampings so that bodies could ever stop. But, as i assume, because of my gravity vector to be constant length – i cannot force the bodies to stop moving completely. It always tries to move itself to the screen center and the smallest possible speed for them – is the length of this gravity vector.

If i only had one body, i would not perform steps 2,3 when the body is closer to the screen center then the gravity size is. But i can not bind bodie’s position to the magnetic field center because the two bodies will never take the exact middle screen place since they will collide with each other. So i cannot make my gravity vector variable, and playing around with any frictions do not do the trick, maybe some step hack could help, but i think what i need is to implement some sort of bouncing counter force or something of that kind.

I am new to box2d, and not very good with physics.

What may also be important is that i set the bodies speed with the SetLinearVelocity method.

Maybe i am just missing something, maybe there is some native for box2d way to achieve this. Any help appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T08:42:42+00:00Added an answer on May 26, 2026 at 8:42 am

    Did solve this issue by changing world scale. “Box2D also uses inelastic collisions when the collision velocity is small. This is done to prevent jitter.” http://www.box2d.org/manual.html
    After reading that i figured out that i should make my acceleration vector small enough so that box2d used this inelastic collisions and prevent its jittering in “native” way. So increasing WORLD_SCALE by 4 times made the distances between bodies and the screen center big enough. Playing around with new numbers for gravitation and friction powers made the trick.

    Regards, Igor

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some ASP.NET web services which all share a common helper class they
I have some C# / asp.net code I inherited which has a textbox which
I have some kind of test data and want to create a unit test
We have some files on our website that users of our software can download.
I have some code that can convert a single color in a template image
Have some validating problems which seem to appear only when using the Auth component.
Have some Perl code which is using the DBI module - (the code is
Have some variables that I need to perform validation on. Pseudocode is as follows
I have some UI in VB 2005 that looks great in XP Style, but
I have some code for starting a thread on the .NET CF 2.0: ThreadStart

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.