Box2d - options for the mouse joint

Started by
4 comments, last by SriLumpa 13 years, 1 month ago
Hi,
I don't know if here is the correct place to post it, but please move it (moderators) if it is in the wrong topic.

As I can see, many many people are using Box2D as the physics library of choice in their games and some problems and solutions are starting to get "padronized" in a certain way.

therefore I want to ask you guys if any of you know of the options that one can have on how to move an object using the mouse while still interacting with the physical world. I've tried to mouse joint "way", but the object get such an absurd momentum that everything is blow away by it. The effect I want to achieve is that of moving a feather, where it can't move any other object on the screen, but is held by the others, etc.

many thanks!
Advertisement

The effect I want to achieve is that of moving a feather, where it can't move any other object on the screen, but is held by the others, etc.


I think it is hard to do while keeping the real physics running. Maybe you can try setting your body's mass to 0 (or near) while moving it.
Also, you will probably get more help on the official box2d forum.
Rather than joint, you might want to 'attach' the body with a spring that gets controlled by mouse, that should do it...
I use chipmunk physics but the idea is the same. When I grab an object, I reset its forces, set its moment of inertia to INFINITY, and cap its angular speed to 0. It locks the object into place until I'm ready to resume the simulation.

[quote name='draconar' timestamp='1297964870' post='4775486']
The effect I want to achieve is that of moving a feather, where it can't move any other object on the screen, but is held by the others, etc.


I think it is hard to do while keeping the real physics running. Maybe you can try setting your body's mass to 0 (or near) while moving it.
Also, you will probably get more help on the official box2d forum.
[/quote]
that is the problem. I've posted 3 or more messages on the official forum but I was ignored. Dunno what is going on...



Rather than joint, you might want to 'attach' the body with a spring that gets controlled by mouse, that should do it...


I like this approach very much. I can visualize it but I still dunno how to implement it. There will be a body (mouse joint?) which is a spring, and connected to that spring will be the body I wan't to move, correct? I'm just not seeing how I will attach the spring to the mouse, but, yes, this is the effect I want to achieve.

cheers!

I like this approach very much. I can visualize it but I still dunno how to implement it. There will be a body (mouse joint?) which is a spring, and connected to that spring will be the body I wan't to move, correct? I'm just not seeing how I will attach the spring to the mouse, but, yes, this is the effect I want to achieve.


Actually I'd say that the mouse joint does something very much like that spring thing already, so I'm not sure you would gain much.
Also, my suggestion of setting the moving body's mass to 0 is probably not working, if the force from the joint can transfer to other bodies in contact.

Another idea is to set every other body to static when you want to drag, and then reset their original properties when you resume the simulation.

This topic is closed to new replies.

Advertisement