- Home /
Raycast stops working for big scaled objects sometimes
Hello guys :)
somehow i got a strange problem. So i have a very small but highly scaled 3D model of a skull with a mesh collider based on the model's mesh. I had to scale it that large for some complex reasons i don't want to bore you with. Now i want to cast a ray on this model. This worked fine as it was scaled with (20, 20, 20) but since i had to scale it to (150, 150, 150) it won't work at points which are just a little farther away (mostly the edges of the cheeks or the area between the teeth and the chin) but works again at really far away locations. If i zoom to the ignored locations it will work again. In every case DrawRay shows me that the ray is hitting the model (seen in the next pictures).
First i thought the ray may be too short but neither Mathf.Infinity, float.MaxValue nor some random really high value have helped. Then i read about that the origin might be in the collider of the skull and so ignores the collider. But this also wasn't the case. I read many other articles about raycast problems but no solution solved my problem. Any ideas what could be wrong here?
Answer by Globox91 · Jun 17, 2016 at 04:01 PM
I have no idea if one can say i solved the actual problem but in any case: i have found a workaround for it. So if i scale the model in the import settings of the mesh and not in the editor the raycasting starts working again. No idea how this comes but it works :)
Answer by agentofzurg · Mar 12, 2017 at 07:09 PM
@Globox91 I just wanted to say thanks for posting this info. I've been searching for an answer for my mysterious raycast problem, and I had the same issue as you - the raycast stopped working after I scaled up my mesh collider. It's now working again, thanks to you!