Collision on zero-velocity particle

This one has me stumped a little. I’ve figured out that in order to use .OnParticleCollision() your particles need to have some velocity.

The problem with that is that I’m trying to make stationary coin pickups. I don’t want to give them velocity as then they start moving.

Does this mean that I can’t use particle collisions in this case?

One possible - but ugly - avenue of thought is to counter the particle velocity by moving its parent in the opposite direction at exactly the same speed as the particles, thus giving the illusion that they’re not moving. I’d rather not do that though.

Any and all insights much appreciated! :slight_smile:

Pretty sure OnParticleCollision() doesn’t require velocity. Where did you get that information?

Seeing how particles need some internal velocity to act as a particle I’ve decided to try the following approach. It gives particles minimal velocity and reverses the velocity every 0.5 seconds. This makes the particles seem like they’re stationary. But in actual fact they’re ever so slowly moving in alternate directions. And this makes collision detection work.

This script goes on the game object that contains the particle system. I’m not too sure about the performance overhead of this! But I tried to minimise overhead by only updating every 0.5 seconds.

using UnityEngine;
using System.Collections;

public class particleVelocity : MonoBehaviour {

	private ParticleSystem s;
	private ParticleSystem.Particle[] parts;
	private Vector3 velocity = new Vector3(0,0,0.01f);

	void Start() {

		this.s = GetComponent<ParticleSystem>();
		InvokeRepeating("updateVelocity", 0, 0.5f);

	}

	private void updateVelocity() {

		this.velocity = -this.velocity;
	
		this.parts = new ParticleSystem.Particle[this.s.particleCount+1];
		int l = this.s.GetParticles(this.parts);
		int i = 0;
		while (i < l) {
			this.parts*.velocity = this.velocity;*
  •  	i++;*
    
  •  }*
    
  •  this.s.SetParticles(this.parts, l);* 
    
  • }*
    }