There are always a million ways to do one thing. sometimes is is very clear what the right way is, but usually it depends on the developer and on the specific use case. in the case of an object following the mouse (like the plyground) you dont need a delta (which is the change between current and last value), since you always set the position to be the current mouse position (current collision between mouse and scene, to be exact).
You can use another event - on collision (or on mesh intersects), and stop following the mouse in cas the object intersects with the target mesh. so, technically, you check if the mouse “collides” with this object (the wall), and dont update the position of the followed mesh, if it does. Does that make sense? or did I make things complicated?