PDA

View Full Version : need help on particle event collisions


NaughtyNathan
09-08-2010, 04:03 PM
why do you have a space in front of the name "bucket" in all those strings..? That would probably invalidate any comparisons...

and why do you check the same thing three times..?

:nathaN

bigpond
09-08-2010, 04:03 PM
hi guys, i've been trying to figuring this out on whats wrong on this procedure.
im really new at this btw
the purpose of the procedure is to set the collisionCheck attribute to 1 whenever
the particle hits the defined object which is in this case a bucket,
here is the procedure :
global proc eventProc (string $particle, int $Id, string $geoObj)
{
if (( $Id == 120) && ($geoObj == " bucket1")) {
setAttr ($geoObj + ".collisionCheck") 1;
}
if (( $Id == 120) && ($geoObj == " bucket2")) {
setAttr ($geoObj + ".collisionCheck") 1;
}
if (( $Id == 120) && ($geoObj == " bucket3")) {
setAttr ($geoObj + ".collisionCheck") 1;
}
};
and nothing happens........ (maybe because it not meet with the right condition to execute the command).

so far, i assumed that the problem is in the ($geoObj == " bucket") statement,
because when i tried to type like this
global proc eventProc (string $particle, int $Id, string $geoObj)
{
if ( $Id == 120) {
setAttr (" bucket1" + ".collisionCheck") 1;
}
if ( $Id == 120) {
setAttr (" bucket2" + ".collisionCheck") 1;
}
if ( $Id == 120) {
setAttr (" bucket3" + ".collisionCheck") 1;
}
};
works okay.

so, can you help me with this one guys ?

jaydru
09-08-2010, 05:00 PM
wtf... is nathan really that good that he can answer your questions before you even post them XD

bigpond
09-08-2010, 06:04 PM
hi Nathan,
why do you have a space in front of the name "bucket" in all those strings..? That would probably invalidate any comparisons...
i've tried eliminate the spaces within the string bucket name, and still doesnt work.
and why do you check the same thing three times..?
i forgot to mention it, i do that because i have three colliding objects (bucket1,bucket2,bucket3)

im really curious about this, because i manage to did this succesfully once. and when i tried it again. it doesnt work anymore.

royg
09-08-2010, 11:00 PM
i've tried eliminate the spaces within the string bucket name, and still doesnt work.Yes, but why are they there in the first place? Is the bucket in your scene called " bucket" or "bucket"? It matters, and you don't really seem to understand this.

royg
09-08-2010, 11:09 PM
I'm assuming those spaces aren't meant to be there. What I don't really get is that if you're sending the name of the object to your procedure "eventProc" why do you then need to check its name? Anyway...
global proc eventProc (string $particle, int $Id, string $geoObj)
{
if ($Id == 120)
{
if (`match "^bucket*" $geoObj` == "bucket")
{
setAttr ($geoObj + ".collisionCheck") 1;
}
}
}Excuse my horrible string checking

bigpond
09-09-2010, 04:47 AM
thanks for the input royg !, yes, as you can tell. im really just starting to learn MEL
and need to do a lot of studying.
as for the namespaces, i put in there not because the object name have spaces but as the Maya read my proc like this;


...
eventProc( "particleShape1" , 135, " bucketShape1" );
eventProc( "particleShape1" , 136, " bucketShape1" );
eventProc( "particleShape1" , 136, " bucketShape1" );



after noticed that, i realize that my string $geoObj statement is always pointed on the objectShape
maybe that's why my proc not executed, because maya are looking for bucketShape1 and bucketShape1.collisionCheck
so,i put some fix to the proc, not the best approach but it manage works pretty well :)


global proc eventProc (string $particle, int $Id, string $geoObj)
{
if (( $Id == 120) && ($geoObj == " bucketShape1")) {
setAttr (" bucket1" + ".collisionCheck") 1;
}
if (( $Id == 120) && ($geoObj == " bucketShape2")) {
setAttr (" bucket2" + ".collisionCheck") 1;
}
if (( $Id == 120) && ($geoObj == " bucketShape3")) {
setAttr (" bucket3" + ".collisionCheck") 1;
}
};

but if i try to eliminate the spaces the proc will not work.
(ugh, its so confusing but interesting at the same time)

royg, im going to study your proc now. and try to elaborate it with my scene and my proc
thanks for the brainstorming guys ! really appreciate it.

CGTalk Moderation
09-09-2010, 04:47 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.