Particle Id error


#1

Hey,
weird problem:

we’ve got parent particles emitting child particles. But then we’re querying the parent particles position. Problem is - I THINK when the parent particle dies, the child particle is querying a particle that doesn’t exist anymore. So I get this error.
How should we go about checking if parentId exists? It’s getting late so I’m sure there’s an easy solution and I’m just ignoring the obvious.

Runtime Before Dynamics

// Variable declarations
float $childParentId = child_tendrils_0Shape1.parentId;
vector $pos = `particle -at position -id $childParentId -q parent_explode_01`;

child_tendrils_0Shape1.position = $pos + pbf_ctrl_01.childRandPosition;

Error

// Error: line 2: Could not find particle with id specified. Please check id value in the query command // 
// Error: An execution error occurred in the runtime before dynamics expression for child_tendrils_0Shape1. // 

Best,
-cw


#2

Hi cw

First idea that hits my head is to check the parentId - variable if it’s anything feasible and make a condition check against that.

Other way would be to add a custom attribute to child particles and flag that to false when the parent dies and check a condition against that.

/risto


#3

Hey,
thanks for the response.

So I’ve tried the following code, but it returns “no”, even though pt[8] exists in the scene.

float $id[] = `particle -at id -order 8 -q parent_explode_0Shape1`;

if (`objExists $id[0]`) print "Yes";
else print "no";

My plan would be to query the childId and check if that value for the parentId exists. But I can’t get the above code to work yet.

Any idea?

-cw


#4

Ok

so now there’s couple of things I think need clarifying:

  1. are you emitting from your parent particle using the ‘emit’ - command ?

if yes, then the parentId will be zero and you have to flag your child - parent relationship yourself. For example to the particleShape you’re emitting add ‘parent’ - attribute and feed your particleId into that in your emit - command.

  1. are you using your parent particle as emitting object ?

if yes, then I fail to see why you need to use ‘particle’ - command to get this stuff ? Why can’t you just query your parentId’s in your child particle’s expression and do whatever you need to do with that ?

If you could elaborate a bit what you’re about to achieve it would be easier for me to help you. Can you ?

And for the record, with ‘particle’ - command you should use -order or -id, not both :slight_smile:

/Risto