how to ignore physic reflection in some condition

hi
i have some problem in physic. i have some boxes and a ball i like when ball collide with box i calculate something and if some condition occur ball continue path and not have reflect. i search net and read something about ignore collision and ignore mask collision but none of them is good for me because i need calculate parameters exactly in collision time.
so what can i do in this situation?

you need to raycast to see if the ball will be hitting something it should pass through. Btw reflect doesn’t exist in physics. It calls it bounce.

thank for your suggestion.
i should raycast in which direction? and with how many distance to avoid change unnecessary object parameter?

The raycast direction = rigidbody.velocity of the ball. Unnecessary object won’t happen, the raycast stops at the first it hits. Unless you use RaycastAll.

but i use gravity and maybe ball never touch the box if only i get first hit and i change some flag in unnecessary and sometimes maybe i have more than a box back to back and ill of them should change flag.
2nd problem is if i raycast in velocity direction and hit object maybe hitting point is on corner of two box and i should check both of them but i have only one hit point in this situation what should i do?

hippocoder thanks for your suggestion. i solve my 2nd problem in previous post by add temp sphere in ray collision point by ball radius and check that collisions and finally calculate conditions and change properties.

To stop a collider affecting other colliders try setting the collider’s size/radius to 0. I’m 100% sure this will have 0 effect, so testing should be done. I suppose you could always change the layer of the objects then set them back afterward but it really depends on the details of your game.