Make object "dodge" when particle nears

Spent some time googling this to no avail.

I wish to make my game object (let’s say a cube) move to the left or right when approached (not struck) by a particle.

If the particle was, in fact, a game object, one approach would be for the target object to emit a cone-collider that, OnTriggerEnter(Collider other) activates the movement. But you can’t do that with particles.

OnParticleCollision doesn’t work because it requires the collider to be not-a-trigger, which means the cube would have an enormous colliding cone sticking out the front of it messing with everything it hits.

OnParticleTrigger might work, but a) I have no idea how to make it happen and b) I can’t seem to add a collider in the box on the particle trigger inspector.

Please help me?

So it looks like the problem you are having is not the movement or particles in general. It’s just about the collision. The idea you have with the “enormous colliding cone sticking out the front” is pretty good if that works for you. You can just put that collider in a different layer then the rest of your level. That way the collider will only interact with anything else on the layer. You can read more about it here: Unity - Manual: Layer-based collision detection.


Just did a little test with it. You have to go into the inspector of your particle system and enable collision or trigger. This will fire the function “OnParticleTrigger()” or "OnParticleCollision() depending on what you use. This function has to be in a script that is attached to your particle system. After that it is just a matter of coding the interaction.