- Home /
How to pick up an object and make it follow the cursor, but realistically?
We're making a 2D game where one of the main mechanics is picking up objects with a cursor and positioning them properly (i.e. picking up a log, rotating it and leaning on a wall, so you can use it as a bridge), but not using regular rotations, only 2D physics.
The picking system should look like this:
You click on the object that you want to pick up
The exact point that you clicked on becomes an anchor/rotation axis
You move the object and it behaves the way a normal physical object would (like if you held a bottle by its cap and swung it around) - it interacts with other objects, rotates, moves in the XY plane.
You release the object with another click
How to make this anchor point exactly the clicked point, not the centre of mass?
But it's not the biggest problem - it's the joints. We've tried giving the desired object all of the possible joint types and none of them has ever met the expectations. The physics were terrible no matter what, e.g.:
When the object approaches the ground collider, it goes nuts - it starts bouncing off the ground, either uncontrollably and chaotically, or in swinging motion (like an upside-down pendulum). Even though the material has 0 bounciness.
When you try to lay in on the ground, this movement is unexpectedly slow. When you think it would hit the ground, it rotates like in slow-motion (speed of which is independent of the value of friction)
The overall outcome is just laggy - sometimes the object doesn't move continuously but teleports to another place
Is there any way you can make it work? Maybe in some other way than joints.
Your answer
Follow this Question
Related Questions
Help I can not understand how to do it with joints 2 Answers
Hinge Joint rotating on its own 0 Answers
Physics gun like in Garry's Mod? 3 Answers