Best way to move an object to a specific point

Hi,

I am a newbie to Box2D and thought this must be a very basic question, but couldn't manage to find an answer.
I am developing a game and there's some situation that I need to place an object to a specific position right away with mouse or programmatically.
I know there's MouseJoint and SetTransform.
But, the thing is,

1. with MouseJoint, there's always little bit of friction and damping so it's hard to place an object to the "exact position" at the "exact time".
Is there a specific setting I should make with MouseJoint to achieve this?

2. with SetTransform(), the object I'm trying to move is connected to other objects through b2DistanceJoint and I still want the joint to work (affecting connected objects' position) while I'm moving the object, which is not the case with SetTransform().

What would be the way to move objects for me?
thanks a lot in advance.
🙂
You can use SetLinearVelocity to move things around. If you want it not to be affected by other bodies it is connected to, you will have to make it a kinematic body (and the other bodies dynamic). Making it kinematic will also let you ignore gravity.
Thanks.

I always have trouble with moving objects with SetLinearVelocity().
SetLinearVelocity() always affected by friction and damping, so it's hard for me to move things to a specific point.
When I try to drag an object to a mouse position with SetLinearVelocity, the object moves too slowly because of the friction and usually moves "gradually to" the point, not to the "exact" position.

Maybe I'm not setting the friction and damping or other settings incorrectly..?
Could you please show me an example?
What is causing friction? Could you turn the friction off while moving it? Kinematic bodies would care about friction.

The code is not complicated, it's just the good old "speed = distance / time" :
Code:
b2Vec2 distance = destination - currentPosition;
float time = howManySecondsToGetThere;
b2Vec2 speed = distance * ( 1 / time );
body->SetLinearVelocity( speed );
b2FixtureDef fixtureDef;
fixtureDef.shape = &dynamicBox;
fixtureDef.density = 0.f;
fixtureDef.friction = 0.f;
fixtureDef.restitution = 0;
fixtureDef.isSensor = true; // stop collision detection

body->CreateFixture(&fixtureDef);
body->SetLinearDamping(0);

Even if I set my body like this, there's always friction and inertia.
With SetLinearVelocity(), the body moves slower and it's hard to make it STOP at the destination point (my mouse pointer).
Which settings should I change?
Thanks a lot!
?
As it gets near the destination point, 'distance' (in my code snippet above) will become near zero, therefore 'speed' will also become zero. I don't see why the body would continue moving when you're setting the linear velocity to zero...
Yes, Yes!!
You're right.
I was setting the time wrong.
I still need some adjustments in my code, but I think I'm getting there!

Thanks a lot!!

Original thread: https://box2d.org/forum/viewtopic.php?t=9800