I’m trying to implement a means of keeping particles within a box in a UI menu. Generally, if you put a few balls in a box, closed the lid, then shook the box: that’s the behavior I want, but only on the X and Y axes, as this is in a UI menu.
Details
In my UI screen I have a canvas, and in that canvas is a game object (I’ll call this the container) with a rect transform. It represent the title bar of that screen. As a child of the container I have a particle system (and some other stuff like text).
The particle system emits from an edge shape on the left, throwing particles toward a point on the right. The particles travel mostly on X axis, but over their lifetime they may gain slight velocity on the Y axis.
I want to constrain the position of the particles to within the container’s rect bounds. When the particles hit the bounds, they should bounce and continue their travel. Like balls in a box.
I’ve played with collision and masking, and have spent the past 2 days searching for solutions, and I’ve come up empty. This seems like it should be simple.
The closest I’ve gotten has been using Plane colliders, but no matter where I position the plane(s), the system always collides with it on the left first, and then bounces on top of it – they don’t act like planes, no matter how I rotate them; they act like cubes.
I also messed around with the emit shapes, but none seem to provide the behavior I want. I tried using World collision but it didn’t help, though I may be missing something.
I can’t seem to define a bounding area for the particles to collide within. Any help would be appreciated.