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:
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