Skip to content

How to enable a mask for raycasts #1347

Closed Answered by jrouwe
benjaminleezhiyuan asked this question in Q&A
Discussion options

You must be logged in to vote

I would suggest reading the collision filtering section: https://jrouwe.github.io/JoltPhysics/#collision-filtering

Basically, you should be using the BroadPhaseLayerFilter/ObjectLayerFilter interfaces to filter out the hits. The version of CastRay you're using will return the first hit that wasn't filtered, so if the object is 'behind an object' then you will only see the object that comes first unless you filtered the hit out using a filter function. Given that you want to use bitmasks for collision filtering you should probably take a look at ObjectLayerPairFilterMask, ObjectVsBroadPhaseLayerFilterMask and BroadPhaseLayerInterfaceMask.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@benjaminleezhiyuan
Comment options

Answer selected by benjaminleezhiyuan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants