Hi guys. I will cut to the chase.
I have a player who has a body made rectangled shape(with cut corners of 1px width) and a crate that he can pick up. Crate has rectangle body(also with cut corners).
Both bodies are dynamic. Now what I need, is that when player will pickup the box, the box will be "glued" to the player's position, so whenever you move the body of crate will move exactly like the player. If the crate(that has body a bit in front
of body of the player) will go into colision with some wall in front, the body of the player will not move further too.
Now I heard that this can be achieved by WeldJoint(to some degree, but some small movement is acceptable) that kinda "glues" two bodies together. I tried everything, but I just can't make it to work.
This is how I tried to do it. First I move the body of the crate using SetTransform method, and then I create a joint between those two boddies.
WeldJoint weldjoint = new WeldJoint(playerBody, crateBody, playerBody.WorldCenter, crateBody.WorldCenter);
As far as I read I have to give the anchor points in the world space, not in local space(Vector2.Zero for example), and I do it like that. I tried with Vector2.Zero's too btw, with no result.
As far as you can see it's very simple, and I simply don't understand how it won't work. Also tried make the crate body with no collision categories just before it's picked.
I am using the XNARenderer so I can see the boddies and I don't see any problems with that. I tried linearJoint too just to check it, but also can't make it to work.
Am I missing something here?