Hey guys, I’m brand new at Unity so please bare with me if this seems like a simple question. I’ve added the DragRigidBody script to my GameObjectA and would like to freeze that GameObjectA at a specific x,y,z coordinate when the user drags the object over those coordinates. Basically I’m trying to create a snap to point on a different GameObjectB that the user can drag GameObjectA towards and click to.
So these are the rough steps
//Check distance between both objects
float distance = (objA.transform.position - objB.transform.position).magnitude;
//If distance is less than X
if(distance < 1)
{
//snap first object to the other objects position
objA.transform.position = objB.transform.position;
}
Adapt the code to your own needs.