where should I input type_mask in PhysicsDirectSpaceState.intersect_ray() in Godot 3?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By icqqq

In Godot 2, there is a parameter called type_mask in PhysicsDirectSpaceState.intersect_ray(), but in Godot 3 the parameter is gone.

How can I achieve the same function of type_mask in Godot 3?

Thanks

:bust_in_silhouette: Reply From: quijipixel

The last parameter in the function is the collision layer int :

intersect_ray ( Vector3 from, Vector3 to, Array exclude=[ ], int collision_layer=2147483647 )

You have to provide the full int with all the layers set.

so how can I achieve the same effect in type_mask, if I want to mask all Rigidbody in the ray cast?
I am not quite familiar with the collision later

Thank you.

icqqq | 2018-02-05 03:06

You have to set your collision layers. Here is a link of a thread explaining how they work. The last parameter in the intersect_ray is an integer, every bit work as a boolean for every collision layer. Here is another link to a thread explaining how to set the bits you need.

quijipixel | 2018-02-05 04:19

so you mean if I want to mask all Rigidbody, I need to put all rigidBody into the same collision layer so that my intersect_ray doesn’t test on that layer?

icqqq | 2018-02-05 06:16

Exactly, If you don’t want your rigids to trigger the raycast then create a collision layer for all you rigids (you can name them now if you wan’t, in the Project Settings), you can even set the collision layer of your rigids on the _ready of everyone. Then just set the collision_layer integer bit of that collision layer to 0.

quijipixel | 2018-02-05 11:15