- Home /
Detecting if object1, being hit by raycast, is colliding with another object
Hi,
Player -------(Raycast) ---------> T (2 rigidbodies attached together forming a "T")
My question is, how to detect if object1, that the raycast is touching, is colliding with object2 ?
Thanks.
Please rephrase the sentence, it's hard to tell what you mean.
Do you mean player and T, or the parts from the T as object 1 and 2?
Yes, T is composed of two parts. Both parts are colliding with eachother. I'd like to know if I hit one part using a raycast, how can I know if this part is currently colliding with another object ?
The object that you're raycasting against could save colliders OnCollisionEnter and delete them in OnCollisionExit. When raycasting them, call a function on them where they check if they currently have some collision going on.
You could also keep checking for a bool OnCollisionStay that gets set on raycasting them. You would need to reset it OnCollisionEnter and loose that one fixedupdate step. But thats ridiculously picky ;)