# How to get local point inside a body where mouse click occurred in box2d?

I need to find out the point inside a body, lets say a rectangular object, where the mouse was clicked on. I'm makin a game where the force will be applied depending on where the mouse was clicked on the body. Any ideas?

Will body.GetLocalPoint(b2vec2) work? I tried by passing the mouse coordinates when the click occurred when inside the body but if the body's position is (400,300) in world coordinates then for trace(body.GetLocalPoint(new b2vec2(mouseX,mouseY)).x); I get some value between 380 to 406 or something (eg. 401.6666666). I thought getLocalPoint will give something like x=-10 when clicked to the left of the centre of body or x=15 etc when clicked to the right.

Language is As3 btw.

I got the point inside the body by passing the proper values of arguments. GetLocalPoint() needs its arguments in the correct pixel to metre ratio. Also I'm supposed to pass a world point.

m_targetX = ball.GetWorldPoint(ball.GetLocalPoint(new b2Vec2(mouseXPhys, mouseYPhys)) ).x * m_physScale;
m_targetY = ball.GetWorldPoint(ball.GetLocalPoint(new b2Vec2(mouseXPhys, mouseYPhys)) ).y * m_physScale;


This gives the required point inside the body in world coordinates. Donno if there's an efficient way but it is good for now.

mouseXPhys = mouseX / m_physcale;
mouseYPhys = mouseY / m_physcale;

m_physcale = 30; //my pixel to metre ratio.