Question by
HzoN · Feb 16, 2016 at 05:26 PM ·
particlesparticlesystemcollision-error
Stationary particle system to collide with game objects
Hello,
I'm trying to create a world based on 3D- point clouds, that should be represented by a stationary particle system. I've successfully created this representation, but the collision detection of the particle system does not work.
Currently I am trying to get a cube to notice collisions with the particles. Is this possible?
My goal is to find collisions with the particle system, then count how many particles is colliding with the object.
Here's the settings of the particle system & cube object.
And here's the code:
function OnParticleCollision(other: GameObject) {
print("collision");
}
function Start() {
// part = GetComponent("ParticleSystem");
collisionEvents = new ParticleCollisionEvent[16];
var line = sr.ReadLine();
var nrOfParticles = parseInt(sr.ReadLine());
line = sr.ReadLine();
var CA : float[,];
//CA = support.CreateColorArray();
Support.TestFunc();
CA = Support.CreateColorArray();
var Quat = new Quaternion();
particles = new ParticleSystem.Particle[nrOfParticles];
var intensity = 1;
line = sr.ReadLine();
var res = line.Split(","[0]);
var i = 0;
while (line != null) {
res = line.Split(","[0]);
intensity = parseFloat(res[3]);
particles[i].position = new Vector3(parseFloat(res[0]), parseFloat(res[2]), parseFloat(res[1]) );
particles[i].velocity = particles[i].velocity.normalized * mParticleSpeed;
particles[i].color = new Color(CA[intensity,0], CA[intensity,1], CA[intensity,2]);
particles[i].size = 0.1f;
i++;
line = sr.ReadLine();
}
nrOfParticles = i;
print(i);
part.SetParticles(particles, nrOfParticles);
}
Any help is appreciated. Thank you,
Comment
Your answer
