kinematic, static or just dynamic object? an other physics questions

Hi all,

I am producing a new game by using Game edition and its physics and I wish to know what type of object I should define for following situation:

  • draggable object that will interact with a ball, let’s say baseball, so that baseball will be controlled by user.
  • the other object is the ball, of course.

So, I define the ball as “dynamic” with friction=0.3, bounce=0.8 and radius=50

and my baseball as “static” because I don’t want any bounce or gravity effect on it. But, I’ve read that for draggable objects, it should be kinematic.

The point here is: if I wish user hits the ball with the baseball, and the baseball is controlled by the finger (i.e. touch/move event) how I must define this piece of code?

I just tried different approaches and I can’t achieve the desired result. For instance, what object I must apply force? What kind of collision detection I must use (i.e. began cycle or postSolve?

The general behaviors of my code are not as desired.

Do I need to apply force to the ball after detect x, y force of the movements of the baseball (like you do on the pool sample code) inside baseball touch event or I can relay on collision detection postSolve where the interaction of two dynamic objects is resolve on postSolve?

In resume, what I need is something (in this case baseball object) to interact and apply a force to a ball, based on user movement of the baseball. Can someone point me some idea, sample code, direction, orientation, anything…?

Kind regards,

Flavio.
[import]uid: 3022 topic_id: 1570 reply_id: 301570[/import]

This is sort of a frequent Box2D question, actually! The issue is that you only get a collision if at least one of the two objects is dynamic, but dynamic objects fall under gravity and are therefore hard to make draggable.

Can you describe your game in more detail? For example, are you dragging the BALL, or the BAT that hits the ball?

Also, do you actually need gravity? If you’re doing an overhead view of the baseball game, you should just set gravity to zero. At that point, nothing will “fall” and you won’t need to switch bodies to kinematic to keep them from falling.

Regarding collision phases: use the “postSolve” phase if you want to measure the collision force as a number, since that data is only available after the collision has been fully resolved. If you just want to know when a collision happens, you should probably listen for the “began” phase instead.

But note that there might be other forms of input you could use, besides the actual collision force: for example, you could use touch tracking to see how fast the player “flicks” the bat (and in which direction they flick), and then apply a force to the ball based on that. This would be similar to “SimplePool”, which uses the length of the “cue line” to calculate the force and direction to hit the ball with. I’m guessing this method may be a LOT easier, since you can interpret the touch data in whatever way feels “right” for your game controls, rather than literally trying to drag a bat with a finger.

[import]uid: 3007 topic_id: 1570 reply_id: 4475[/import]