hello i decided to join box2d i m new one in Game programming. i have one issue how can i apply momentum on a body let me clarify the issue like in pinball game suppose i have a stick if ball touch that stick then it gets speed as i did but this is not what i want, what i want when i move the stick if it touch the ball the ball should get the real momentum like in baseball Or in Cricket ..
Thanks
Umer Sufyan
Let the pin be a static body and have restitution higher than 1. That'll let any object that touch the pin get higher energy than before it hits. Having the value 1 will exactly reflect the balls momentum, and lower will absorb some of the energy.
However, I wonder if you'll be able to do anything in programming if you can't even master punctuation in common English. Your post is difficult to read, and honestly a bit hard to take seriously.
Thank you for your good reply i m weak in English 😢 and trying to overcome this problem.
Indeed it does work but here is a one problem with that way , Actually i want to achieve the speed with the movement of stick .
Suppose a scenario , In pinball game if you notice the stick doest not apply any force on ball when the stick is in rest but when we move the stick it applies or exerts a force on ball as in real world we see, Can you give me some guide line regarding this.
thanks for you valuable suggestion Actually i want to make a pinball game where the stick (i think should be static) so it is(according to my view) . Should i change it to dynamic and apply a motor to it so that when stick hits the ball it should move like in pinball game...
Any Ways Thanks 🙂
I'm really confused about what you're trying to achieve.
If you mean the non moving pins and other things on the top of the playfield, then use a static body with high restitution depending on the effect you wish to get. Some pins are just metal with low restitution (<1), some are rubber bands that shoots the ball away which would be a very high (>1) restitution.
If you mean the flipper pads at the bottom that the player controls to flip the ball upwards, then use a dynamic body with a motor joint. Flippers swing to send the ball away, so they must be dynamic.
Static bodies are not meant to be moved around. If they are, you may get unexpected results in the physics because they have infinite mass and doesn't have velocities
Moving => use dynamic body
Stationary, unmovable => use static body
Yes, those yellow things are called "flippers", not sticks. You should make these dynamic and with a motor joint to turn them, just like a real pinball game.