Page 1 of 1

How to cast rays through an object

Posted: Sat Feb 29, 2020 5:43 am
by yanbo2u
i need to shoot a ray from a point to the ground( a box ). but sometimes there could be some unexpected objects getting in the way of the ray. I need to let the ray cast as if the unexpected objects never exist.

is it possible? please advise.

Re: How to cast rays through an object

Posted: Sat Feb 29, 2020 1:19 pm
by yanbo2u
Found a solution from a earlier post.


viewtopic.php?f=4&t=2319

Re: How to cast rays through an object

Posted: Sat Feb 29, 2020 8:02 pm
by Norbo
That post is about getting the entity hit by a ray cast in v1, but it doesn't cover filtering considered bodies, which sounds like what you actually want.

In v1, Space.RayCast takes a delegate that can be used to filter out unwanted candidates.

In v2, the IRayHitHandler you pass to the Simulation.RayCast function has AllowTest callbacks you can use to reject objects before testing.

Re: How to cast rays through an object

Posted: Sun Mar 01, 2020 2:01 am
by yanbo2u
Norbo wrote: Sat Feb 29, 2020 8:02 pm That post is about getting the entity hit by a ray cast in v1, but it doesn't cover filtering considered bodies, which sounds like what you actually want.

In v1, Space.RayCast takes a delegate that can be used to filter out unwanted candidates.

In v2, the IRayHitHandler you pass to the Simulation.RayCast function has AllowTest callbacks you can use to reject objects before testing.
Thanks. It works.