Box2D, speed and acceleration

Hi

I have some question about Physics !

I wonder if it is possible to know the speed and the acceleration of an object and if it is possible to change them ! For example, I want to change the speed direction manually, is it possible ?

My second question is how to give a constant speed to an object ?

I saw Box2D was able to make sleep some object, does it means that number of objects is almost infinite ???

Thank’s

1 Like

You can find answer to most of your questions from the docs:

To figure out the direction of an object, you could just use math.atan2 with the values from getLinearVelocity.

In order to give an object a constant speed, you’d need to set that yourself every frame by using enterFrame listener, for instance, but this may lead to some unwanted behaviour upon collisions if you’d want them to change their movement direction, etc.

Box2D will automatically put physics bodies to sleep if they aren’t active for a few seconds. The main resource drain is dynamic physics bodies. I wouldn’t go about playing with a massive number of dynamic bodies, let alone infinite. :stuck_out_tongue:

1 Like

Thank’s but, I’m not sur to really understand what Velocity is !

Is it the speed or the acceleration.
I can test :slight_smile:

My purpose is to change the direction of an object during it’s jump !
I’ll make a small try !

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.