How to use ProximityPrompt with rectangular objects?

ProximityPrompt works well for square objects as it measures the distance from the center of the object:

But it doesn’t work well for irregular objects like a rectangle.

Here it will work:

image

Here it will not:

image

I think ProximityPrompt should be activated by the distance with the FACES of the object, not the center.

How to solve this?

2 Likes

You can request a feature of this. I like the idea you have!

1 Like

This is my guess for the solution:

if x.X > x.Y and x.X > x.Z then
	local e = tonumber(x.X)
	script.Parent.MaxActivationDistance = e / 2
elseif x.Y > x.X and x.Y > x.Z then
	local e = tonumber(x.Y)
	script.Parent.MaxActivationDistance = e / 2
elseif x.Z > x.X and x.Z > x.Y then
	local e = tonumber(x.Z)
	script.Parent.MaxActivationDistance = e / 2
elseif x.X == x.Y and x.X == x.Z then
	local e = tonumber(x.X)
	script.Parent.MaxActivationDistance = e / 2
end

Makes the ProximityPrompt appear no matter which wall you’re facing on.

Thanks, but this will simply expand the radius to the size of the widest face.
This will cause ProximityPrompt to fire too far when the player approaches a narrower face.

Yeah I know. Maybe we can decrease the radius the more the player is further from the wall?

What if you increase the range of MaxActivationDistance? Place the largest number in size, that is, if the piece measures 6, 10, 14, 14 would be the number for MaxActivationDistance.

Done:

you can check if player is inside are using Touched or region3 and set MaxActivationDistance when player inside of the area
example by @sleitnick

1 Like

Thank you.
Based on your suggestion, I think I could achieve the ideal solution:

1 Like