- Home /
Drag & Drop GameObject with MovePosition shoots other Gameobject away in case of them colliding
I have a object that I move with Rigidbody.MovePosition. Mostly this works fine (or at least better than Transform.Position.....).
But should this object collide with my other object while moving, the other object will shoot away like crazy (except if I move my object very very slowly...).
The other possibility would be to use Transform.Position. But with that my objects will just pass through each other and ignore the collision completly sometimes (I tested the "DontGoTrhoughThings" scrip...it helped a bit but not nearly enough).
The object I can drag&drop is a Kinematic one. The one it sometimes will collide with isn't.
What would be the best way to achieve a drag&dropable object that workst like Rigidbody.MovePosition except for the extreme reaction in case of a collision.
Thank you in advance! ,I have a Object that I move with Rigidbody.MovePosition. Mostly this works fine (or at least better than Transform.Position.....). But should this Object collide with my other object while moving, the other object will shoot away like crazy (except if I move my object very very slowly...).
The other possibilitie would be taking Transform.Position but in this case instead of pushing away the other Object in highspeed it will often just ignore the collision (I tested this "Don'tGoThroughThings" script....it helped a tiny bit but not nearly enough).
The Object I move around is a kinematic one. The other one isn't.
So what would be the best way to make a Object Drag & Dropable while not completly "removing/confusing" the physics ?
Thank you in advance for your help!
Answer by hexagonius · Mar 24, 2018 at 11:09 AM
From testing myself I'd say the best working solution is using the rigidbody as non kinematic while dragging and changing the velocity of it in FixedUpdate like this:
rigidbody.velocity = vectorFromObjectToDestination / Time.deltaTime;
Thank you for your answer. Sadly your solution doesnt resolve the "shooting the other object away in case of them colliding" problem
Your answer
Follow this Question
Related Questions
How may I observe expected physical interactions while using Rigidbody.MoveRotation()? 1 Answer
Collision interpenetration and object getting stuck 1 Answer
Non-convex MeshCollider with non-kinematic Rigidbody? 2 Answers
How do I "remove/disable" collision? 3 Answers
Camera and mesh not colliding 1 Answer