Ignoring collisions with an object except raycast

Hello,

I’m working on a sidescroller and I had the idea of using a mesh that I would test against raycast so that the scene could curve or the character could move through the Z axis by simply following an invisible mesh.

My idea is to use a raycast perpendicular to the plane of the character’s movement. However, in order to raycast test to get the position the character should snap to, the object needs a collider, but then it would interfere with rigidbody collisions. My first thought was to use layers but that does not seem to affect physics. Any suggestions how would I go about this?

Thank you!

make the collider a trigger.

trigger colliders can be raycasted but they doesnt generate actual physical collisions they just know when other collider are touching them so generating events that can be scripted

to make a collider a trigger, just check the box that says “trigger?” or something like that in the collider properties in the editor

hope this helps

Thanks! That’s exactly what I was looking for!