How can I detect if a part can fit between a space or not?

Hello World!

I currently need help on a bug. I know the solution, but I don’t know how to do it.

My problem is :

  • Object clips into the wall or ground when it is being dragged and scaled.

Video :

Perspective Scaling

If you don’t understand what is going on; I am doing a perspective scaling effect in Roblox so the further you are away from an object the bigger the thing you are selecting is. And the closer, it gets smaller.

You can use spatial query (workspace:GetPartsInPart) to see if the part is clipping into anything.
If you just want to make it so that it doesn’t clip, try using a physics-based method of positioning the block (such as with BodyMovers or inverse kinematics)

I’m gonna try this out and notify you what happend.

One question, wouldn’t this remove the illusion of the perspective scaling thing?

Yes, it will, but it’s a solution to your problem. I don’t know much about your game, but I guess you can either

  1. Restrict the size of the part so that it fits
    or
  2. Interpolate the part with physics so it never clips

Option one would be a bit more tedious to do, I imagine you needing to constantly adjust down the dimensions of the part until it stops clipping

Well the solution I figured out to this was moving the part away from the wall relative to the camera’s Z perspective. But I don’t really know how to do that yet…

But first I need a check if the part can fit into that space. So how do I make a check for that?