How to make a gate open by multiple cars and considering the road course?

open gate

I want to open and close a gate depending on a car which comes near to the gate.

The problem: i cannot use distance to the gate because if the street comes by near on the other side, it would open, which it shouldn’t. Does anybody have an elegant solution for this?

I already have the “ready made” solution with distance - which isn’t perfect as i wrote :wink:

And yes, i can make the distance shorter for recognizing the car, but i want to make a bigger distance to open it because i like it more if the gate opens slowly.

For each car that should trigger the gate, create a “trigger box” mesh that is somewhat larger than the bounding box of the object. Make these follow their cars, probably by parenting. Move all of these trigger boxes to their own collection and disable rendering on that collection.

Make a new mesh object. Using geometry nodes, set this object to instance your trigger box collection on “relative”. (So the original mesh object doesn’t even matter.) Disable rendering on this object. (Don’t move it to your trigger box collection though. Then it’d probably bug out, trying to instance itself.) *important edit: don’t forget to realize instances on this collection or constraints don’t work.

Make two empties roughly in the middle of the gate. Give one of them a shrinkwrap constraint, on “outside” mode, targeting your geometry nodes object. Parent it to the other empty for convenience. Use the distance between these two empties as the driver to open your gate.

Tune the placement of the empties (move them together, as one) and the size of your trigger boxes to control the distance where your gate begins to empty. Tune your driver to control the amount that your gate raises. You may wish to give your trigger boxes some C-C subdivision to smooth them out if the placement of the structures leads to unsteady interpolation.


that’s really great!!! thank you! works like a charm. Just a small remark: i needed to use “outside surface” that it works. Outside didn’t work for me though.

You shouldn’t need to do that, and that shouldn’t work. But if you’re happy, that’s all that counts.

Might have something to do with the fact that I forget to emphasize, you need “realize instance” node in your GN.


without realizing instances, my whole setup didn’t work with any setting.

With realizing instances it worked without the “outside” settings, as you can see here:

outside doesnt work

i don’t know, maybe because i am using 3.4. alpha or i am making another mistake.

No, you want “outside,” you just want a larger trigger box if you want the gate to raise for the car at that distance. The trigger box is supposed to push the empty out of the way as the car approaches the gate. The default gate state is down, and when the empty moves, the gate raises.

i really don’t wanna be unfriendly and i don’t wanna be pushing…i just can say, in my blender version, with my file (and i even tried it now with Blender 3.1) …setting to outside doesn’t work, sorry (as i showed in the gif. I hope you can see it, that the empty “jumps back” to its original position). Therefore i marked that empty, so it is orange and good to see)

The empty should not be moving in your video, because the car isn’t close to it. It should move only when the car is close. With shrinkwrap/outside surface it will move all the time, so it won’t be appropriate for use as a “car-detector”.

It’s okay. You’re not understanding how the solution I envisioned works. Continue doing what you’re doing, since you don’t yet have the driver set up, and you aren’t animating the cars, and you’ll see that you don’t want outside surface. There’s nothing wrong with getting a bit further before realizing that.

1 Like

Here, here’s a file demonstrating what I meant, with 120 frames of animation:

gatedemo.blend (872.6 KB)

1 Like

ah ok, thank you very much. I didn’t know it should only move near to it. That wasn’t clear to me and my empties seemed to be too far from each other, that’s why it didn’t work in my case.
And of course i already made the cars animating and everything moved :wink:
I solved it with the other setting by using min(max(…)) :wink: But i will try now the “outside” solution.