Proximity Prompts not working from close/certain angles

  1. What do you want to achieve? Keep it simple and clear!

When my camera mouse from first person view is pointing towards a model, I want it to show a proximity prompt.

  1. What is the issue? Include screenshots / videos if possible!

The proximity prompt does not show when the player is too close, or is pointing at the model from certain angles. Heres a video demonstrating the issue:

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

Tried messing with ALL of the properties of the ProximityPrompt. Nothing worked.

Below is a portion of client-sided code on how a proximity prompt is revealed. The proximity prompt is cloned from ReplicatedStorage and placed as a child of every model spawned in workspace. The client sided code allows for a player to aim at a model via raycasting, which then should reveal the bounding box (this works perfectly), and the proximity prompt which that model has (not working perfectly).

Client-Sided Code:

local lastHitModel = nil

local blacklistedPart = nil

local function performRaycast()
	local origin = camera.CFrame.Position
	local direction = camera.CFrame:vectorToWorldSpace(Vector3.new(0, 0, -1))
	local ray = Ray.new(origin, direction * 20)

	local raycastParams = RaycastParams.new()
	raycastParams.FilterType = Enum.RaycastFilterType.Exclude
	raycastParams.FilterDescendantsInstances = {lockers, player.Character, baseplate}

	local raycastResult = workspace:Raycast(origin, direction * 20, raycastParams)

	if raycastResult then
		local hitPart = raycastResult.Instance
		local hitModel = hitPart.Parent
		if hitModel and hitModel:IsA("Model") and hitModel:FindFirstChild("ProximityPrompt") then
			local selectionBox = hitModel:FindFirstChild("SelectionBox")
			local proximityPrompt = hitModel.ProximityPrompt
			if selectionBox and selectionBox:IsA("SelectionBox") then
				selectionBox.Visible = true
				proximityPrompt.Enabled = true
			end
			if lastHitModel and lastHitModel ~= hitModel and lastHitModel:FindFirstChild("SelectionBox") then
				lastHitModel.SelectionBox.Visible = false
				lastHitModel.ProximityPrompt.Enabled = false
			end
			lastHitModel = hitModel
		end
	else
		if lastHitModel and lastHitModel:FindFirstChild("SelectionBox") then
			lastHitModel.SelectionBox.Visible = false
			lastHitModel.ProximityPrompt.Enabled = false
		end
		lastHitModel = nil
	end
end

claimingPhase.OnClientEvent:Connect(function()
	game:GetService("RunService").Heartbeat:Connect(performRaycast)
end)

Here is also the image of the hierarchy of an average model spawning into the map:

imageofcardboard

Here is the properties I have for the ProimityPrompt:

You are already handling the detection for the prompt in the raycast function, so all you need to do is set some properties on the prompt to make it consistent. It is only enabled when the player is looking directly at it, so just make the MaxActivationDistance large (maybe 5-10 studs) and set RequiresLineOfSight to false.

This will make it so that obstructions don’t stop the prompt from showing (which we aren’t concerned about here because you are checking that with the raycast function), and you can tweak the MaxActivationDistance as much as needed to make it “feel” good (probably would be odd to get a prompt for something you are looking at 100 studs away).

1 Like

Thanks for the response!

The promptproperties image shows the properties setting I used in the video above. MaxActivationDistance is set to 30 and RequiresLineOfSight is set to false. The problems you see in the video are with those settings.

1 Like

This may sound silly but have you verified that these properties are properly staying set during runtime? It’s odd that the selection box is working fine but the prompt isn’t.

1 Like

Yeah, nothing changes during runtime. Thats how the prompt remains : (

I solved the problem. I instead parented an attachment to the primarypart of each model, and then parented a cloned proximitydetector to the attachment.

Lesson learned, don’t parent proximitydetectors to models.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.