- Home /
How can I slow down mouse drag in game ?
Hello, Here is the situation, I have 2 obcejts with coliders, I move one object towards other along X axis and when they collide I disable mousedrag. Here is the catch, when I hit them with quick mouse drag unity is not fast enough to disable my mousedrag before Im deep in the body of the second object. Is there a way I can slow down mousedrag or move my object in constant speed, or perhaps slow down the cursos ?
Thx a lot
Answer by robertbu · Oct 31, 2014 at 06:34 PM
Without your code, it is difficult to make a specific recommendation, but here are some ideas:
Use a spring joint between your mouse position and your object. This is how the standard DragRigidbody.js script drags objects.
Implement your drag and drop code so that the mouse drags and empty game object and you use Vector3.MoveTowards() along with Rigidbody.MovePosition() to move the visible object to the empty game object at a fixed speed.
Decrease fixedTimestep. This will cause the Physics engine to run more frequently and therefore catch overlaps sooner
Use overlap sphere or some other overlap mechanism instead of or in addition to Unity collisions to detect overlaps.
Decrease 'Min Penetration for Penalty' setting in Physics Manager.
Your answer
![](https://koobas.hobune.stream/wayback/20220613170425im_/https://answers.unity.com/themes/thub/images/avi.jpg)