I have a situation where cars go through detection area.
I want that detection area to change color when any car is in it (car object is intersecting with detection object), and change back when there is no car in it.
I could animate this by hand, but I am looking for an automated/rigged solution since there is a lot of cars and a lot of detection areas.
Done perfectly, with any type of (manifold) mesh? Duplicate the car. Make the duplicate non-rendering. Give it a boolean modifier with the detection zone (intersection). Create a pair of empties at the same location as each other, someplace out of the way of the detector. Shrinkwrap one of them to your duplicate.
If there is no intersection, the shrinkwrap won’t do anything, and the empties will stay in the same location, which you can tell by looking for a difference in object coordinates from each empty. If there is an intersection, one of the empties will move, and you can light up the detection zone:
Wow - looks really nice but I assume that I would need separate material for every car ( car are different meshes - but the same material) for detection to work, so I could feed the particular mesh of particular car into the texture coordinate node - am I right?
Maybe a picture of what you want to acheive would help.
If the detection area shape is complex, a detection or boolean trick will be needed. But if it’s a cube or a sphere, a simple driver with a distance property would fit.
Also, it’s not clear what you want when you say :
Do you mean that only the detection object changes its color (and not the car) or do you mean the part of the car inside the detection changes it’s color ?
To do it that way, with multiple cars, you need a non-rendering duplicate mesh for each car, but not a new material-- you look at multiple empties and do some OR logic (which is just a clamped math/add.) The object coordinates are not from the cars in that example, because that wouldn’t give you mesh intersection like you wanted, but from empties that shrinkwrap to the cars if and only if the cars are inside the detection zone.