Raycast hit on object without collider? Is it possible?

Hi there,

I wanted to make a script that reacts when you touch certain objects in the scene but I don’t want to put mesh colliders on the objects just for this purpose.
Is there a way to do a sort of raycast hit and return the name of the mesh object that is in line even if it has no collider component?

Thanks
Pete

As far as I know, it’s not possible without a form of collider attached to the game object.

Technically it’s possible, but you’d have to do all the math yourself. Realistically it’s not possible.

–Eric

I think if the object has a rigid body attached you can get the object name.

Like hitInfo.rigidbody.name

I haven’t tried it but I guess that wouldn’t work. Because, to get the hit info, you first have to get the hit, and that requires the collider…

1 Like

I’m going to test it real quick because I don’t know either and don’t want to miss inform anyone.

hehe :slight_smile: yeah, I might just just give that a miss.
Just thought there might be something simple I was missing out on.
Thanks anyway!

Ok the answer is no you need some type of collider and it can’t be a trigger either. This is tested. :roll:

you can always use a collider set as a trigger. This will not cause collision with objects but will let you hit with rays and what not.

1 Like

Yes, the only trouble was that a few of the objects were skinned meshes and it doesn’t seem like the colision mesh gets animated with the skinned mesh.

Indeed it doesn’t…that would be extremely slow.

–Eric

Yeah, I kinda figured that. It’s okay I’ll just find another angle to attack it from :slight_smile:

why not add a mesh collider as well?
it could be put in its own layer/tag so that only the rays you want will test against it…

this is quiet common in FPS games, you need ‘Actor Collision Mesh’, which will guide gameplay and smooth out steps and floors, then usually you have ‘Projectile Collision’ for bullets, which is where you want accurate poly for poly collision

regarding animating collision mesh with the character… instead, just create a collection of spheres to generally pad out the animated objects volume (similar to ragdoll)

thank you !!!