Maya gotchas - nParticles getting velocity from like, nowhere

Posted 16 October, 2012 Anthony Tan (staring at yet another render. But still loving it for some reason..)

« previous | next »

Here's an interesting one for you. I'm creating some nParticles, and wanting to get trails coming from them (as in, particle trails) so I'm taking the easy/quick option and making each particle in my lead group emit another particle (at about the rate of 1/frame) with no velocity. Should make a nice trail of dots right? right? (Maya 2012x64)

Scene setup

Something basic. Create an nParticle emitter in worldspace origin. Set it to spam out say, 96 particles/sec, speed of say 20, and set it's container particleShape to limit the count at 10. This should give you 10 sphereoids radiating out.

Select your particles and use them as an emitter - for clarity, you only want to do it about 24 particles/sec, and make sure that they are emitted with no velocity. While you're at it, turn the particleShape's rendering to points (it's simpler)

Let's also do something to make sure I'm not going insane - head to your trail particles (probably particleShape2) and give them the following creation expression to make sure that all particles created are grey, and that if they have any velocity at all, they will be bright, alarming, red.

rgbPP = <<0.5,0.5,0.5>>;
if(abs(mag(velocity)) &gt 0) {
	rgbPP = <<1,0,0>>;

and for kicks (and because I know what's going to happen) put this in the post-dynamics script slot. Really, we shouldn't see anything but if there's any particles post-dynamics with an appreciable velocity, we will mark em yellow and print out their ID and birth velocity.

if(abs(mag(velocity)) > 1) {
	rgbPP = <<1,1,0>>;
	print( "particleId:velocity0--" + particleId + ":" +velocity0 + "\n" );
Hit play.. and you should get something like this:

along with script editor readout that shows that all our candidate particles had no birth velocity. *sigh*. So yes, look out, there's weirdness afoot, at least in Maya 2012x64. As soon as I get around to 2013 I'll update and point out if it's an issue there too.

A couple of basic solutions

  1. If you are JUST making particle trails - you can set drag/conserve/damp on the particleShape node to lock them all in place (originally suggested by João Nóbrega in a chat). This is quick, easy, and will work nicely - until you start wanting to like, do something with those particles (like apply a force to them). You still get the issue of particles being generated in places that they couldn't have been.
  2. have the emitted particles run against a new nucleus solver or emit regular particles (which is essentially the same root solution)
  3. run your own custom emitter code (I'll post some up in a later piece if anyone's curious) and add in a custom trap at that first dynamics step.

As always, the takeout appears to be to know your tools - it's not like we're talking about anything that's show stopping, but if you have enough complexity in your system, and you keep being unable to work out that one teeeeeeeny little bug.

(Yeah, I know. I should stop poking at things like this..)

Maya gotchas - the lastPosition attribute of particles
Poking Maya's transform nodes and the worldMatrix
  1. João's and I studied at Escape together (well, sorta, but I digress) and his site is over at