Hey everyone,
I'm making a mouse controlled game where you affect the physics-based gameworld using a box that is directly controlled with the mouse. The box itself doesn't have any collision with the other objects, but I'm using it as a "magnet", so that you can grab other objects, and collide them with each other. The box itself should be a pointer that always follows the mouse perfectly.
Currently, I just set the box to the mouse position and velocity using SetOriginPosition and SetLinearVelocity. When the mouse is clicked, it checks to see whether there are any bodies behind it, and if so, then it creates a prismatic joint between them that is limited to nearly zero travel. This means that you can pick up objects with your "magnet" (mouse pointer).
So far so good, and it seems to work okay. The problem occurs when colliding the object you have picked up with the rest of the world. I have added a test using GetReactionForce so that the joint will break and you will drop the object if you whack it against a wall. However, if you just "scrape it off" slowly against a wall (static box), then the force never seems to get high enough to cause the joint to break, despite the fact that the objects start going crazy. I'm guessing this is because I'm setting the position directly, but the joint is trying to resolve the positions so that the distance is constrained to zero, and none of the objects are intersecting.
Is there some other property I could give the joint? I'd really like to give the position setting of the mouse priority over the strength of the joint.
Any help would be much appreciated!
I'm making a mouse controlled game where you affect the physics-based gameworld using a box that is directly controlled with the mouse. The box itself doesn't have any collision with the other objects, but I'm using it as a "magnet", so that you can grab other objects, and collide them with each other. The box itself should be a pointer that always follows the mouse perfectly.
Currently, I just set the box to the mouse position and velocity using SetOriginPosition and SetLinearVelocity. When the mouse is clicked, it checks to see whether there are any bodies behind it, and if so, then it creates a prismatic joint between them that is limited to nearly zero travel. This means that you can pick up objects with your "magnet" (mouse pointer).
So far so good, and it seems to work okay. The problem occurs when colliding the object you have picked up with the rest of the world. I have added a test using GetReactionForce so that the joint will break and you will drop the object if you whack it against a wall. However, if you just "scrape it off" slowly against a wall (static box), then the force never seems to get high enough to cause the joint to break, despite the fact that the objects start going crazy. I'm guessing this is because I'm setting the position directly, but the joint is trying to resolve the positions so that the distance is constrained to zero, and none of the objects are intersecting.
Is there some other property I could give the joint? I'd really like to give the position setting of the mouse priority over the strength of the joint.
Any help would be much appreciated!