Issue with raycast collisions on special meshes

Hello, I’ve been experimenting with raycasts and I have encountered an issue when casting a ray onto a SpecialMesh.

I have found that the ray will hit the collision box of the original part which the mesh is (parented to/inside of) instead of colliding with the mesh itself as shown below:


This is meant to be a character facing another character; however the other character’s appearing is covered by a grey box from the accessories it is wearing


This image compares the detail of a normal mesh (circled above), which renders correctly, to a special mesh (the head, circled below)

In both images, detail is lost and the Special Meshes are displayed as parts instead of the mesh due to the way the ray interact with them. I tested this using points to mark where the rays hit and the results supported this:
Raycast point issues in Ray Render by Treklatom
The rays in the image above did not collide with the SpecialMesh correctly

This is the code I am using:

    local Params = RaycastParams.new() -- Raycast Parameters
	Params.IgnoreWater = false
	Params.BruteForceAllSlow = true
	Params.RespectCanCollide = false
	
	local Pos = script.Parent.Parent.Parent.AbsolutePosition -- Position of tile to render
	
	local Settings = game.ReplicatedStorage:WaitForChild("Settings") -- Render settings
	local Dist = Settings:WaitForChild("MaxDist").Value -- Max Render distance (distance of ray)
	
	local Cast = game.Workspace.CurrentCamera:ScreenPointToRay(Pos.X, Pos.Y) -- Creates the ray
	local RayCast = game.Workspace:Raycast(Cast.Origin, Cast.Direction*Dist, Params) -- Creates ray cast

I have tried looking for ways to change the collision settings and raycast parameters; however, there are no settings in the part or special mesh which allow me to do this.

If anyone knows how I can do this please let me know.

Thanks for reading, have a good day :slight_smile:

To address this issue, have you considered utilizing the Params.FilterDescendantsInstances property? By blacklisting the parent object containing the SpecialMesh from the raycast, you can ensure that the ray interacts solely with the mesh, potentially resolving the collision discrepancy you’re experiencing.

Thanks for the idea! Unfortunately, it didn’t work as intended as hiding the part also hid the mesh inside of it:

Is there any reason why you’ve opted to enable BruteForceAllSlow? As far as I know, this setting disregards all part collision properties and can significantly impact performance.

I didn’t look much into the setting and I just enabled it to see if it would solve the issue. I’ll try disabling it to see if it makes a difference.

1 Like