i have a box and i need to give it a force to make it do a projectile motion. just like eject the box to air and then the box falls down. I have tried to use joint and applyForce to realize it but they don't work. anyone can give me an idea? thanks for any help.
how to simulate the movement of projectile motion
FlashI have the same problem.
you can define two body
one have a large linearDamping
but this have a problem is that the speed on horizontal will decrease to zero.
you can define two body
one have a large linearDamping
but this have a problem is that the speed on horizontal will decrease to zero.
Projectile motion is a basic result of applied Newtonian physics. If you have gravity and a starting velocity, projectile motion will occur.
(You guys are thinking too hard--just set gravity, velocity, and position, don't apply any friction, and it'll be projectile motion as you know it.)
If projectile motion is the only reason you are using box2d, I suggest learning a little kinematics and doing it yourself. You don't need a physics engine to do simple calculations like this. (I'll help you later, if you decide to do this. Just send me a PM.)
(You guys are thinking too hard--just set gravity, velocity, and position, don't apply any friction, and it'll be projectile motion as you know it.)
If projectile motion is the only reason you are using box2d, I suggest learning a little kinematics and doing it yourself. You don't need a physics engine to do simple calculations like this. (I'll help you later, if you decide to do this. Just send me a PM.)
Thank you for replying.
I know your meaning. If i just simulate the movement of projectile motion i don't have to choose to use box2d. In fact the game I am creating need to use the box2d. the object that make a movement of projectile motion is just one part of the game. I don't know how to give it a force that can make it do a projectile motion. it seems that all kind of joint can't do that. So anyone can tell how to realize it?
I know your meaning. If i just simulate the movement of projectile motion i don't have to choose to use box2d. In fact the game I am creating need to use the box2d. the object that make a movement of projectile motion is just one part of the game. I don't know how to give it a force that can make it do a projectile motion. it seems that all kind of joint can't do that. So anyone can tell how to realize it?
A simple applyForce should do the trick if you have gravity in your world:
Note that the force is in newtons. So, you'll need large values to see something actually happening.
For example, if your gravity is set to 10 you'll need forceY of about -1000 to see the body go up into the air.
Quote:
body.ApplyForce(new b2Vec2(forceX, forceY), body.GetWorldCenter());
Note that the force is in newtons. So, you'll need large values to see something actually happening.
For example, if your gravity is set to 10 you'll need forceY of about -1000 to see the body go up into the air.
Original thread: https://box2d.org/forum/viewtopic.php?t=5494