I’m not sure how to word this. A tractor beam, of sorts. Don’t know how to do that.
I don’t know how to do much, in truth. I’ve barely used Unity at all, so I’ve not exactly got a great knowledge base. Any help would be incredibly useful. Thanks.
Like… a force?
You can accomplish this by calculating the direction towards the desired position in a vector, and use Physics.AddForce() scaled by the distance to smoothly pull it like a tractor beam. Something along the lines of this:
Vector3 velocity = (desired_position.transform.position - object_reference.transform.position).normalized;
object_reference.rigidbody.AddForce((velocity * someSpeed) * (Vector3.Distance(desired_position.position, object_reference.transform.position)), ForceMode.Impulse);
This calculation will also work in 2D, like if you were using Vector2. Be careful increasing the value you multiply it by, too high and it will start to ‘orbit’ the position really fast (Go past it, then have to move back, repeat). If you don’t want the object to be pushed insanely hard if it was really far away, just clamp the distance in a float to be maximum of 1 so that it limits the speed.