View Single Post
# 1 18-02-2015 , 09:42 PM
Registered User
Join Date: Feb 2015
Posts: 3

How to control the ratio of nParticle instances

Hi,

I've been using nParticle instances to create a scene with multiple objects in a crowded environment. However, I am unable to figure out how to control the amount of instanced molecules that are emitted. Any help will be much appreciated.

Here is my creation expression thus far:

$i = rand(0,101);
if($i > 50) nParticleShape1.indexpp = 0;
if($i < 50) nParticleShape1.indexpp = 1;
if($i < 30) nParticleShape1.indexpp = 2;
if($i < 10) nParticleShape1.indexpp = 3;
if($i < 2) nParticleShape1.indexpp = 4;

When I have just the first 3 statements, the expression works fine but the more I add, the more unpredictable results I get. I am certain the answer is in the way that I am writing the script but haven't been able to figure it out. Ideally I would like to have a range of values (i.e. 10 > i < 50) but when I tried using the following: if($i < 50) && ($i >30) nParticleShape1.indexpp = 1; I get a syntax error.

Thanks