# Stop particle velocity via treshold

**URL:** https://forum.highend3d.com/t/stop-particle-velocity-via-treshold/4113
**Category:** Maya
**Tags:** mel
**Created:** [October 16, 2004, 10:00am UTC](https://forum.highend3d.com/t/stop-particle-velocity-via-treshold/4113 "2004-10-16T10:00:50Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![mindsample](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/m/4da419/32.png) [@mindsample](https://forum.highend3d.com/u/mindsample)
#### Post date: [October 16, 2004, 10:00am UTC](https://forum.highend3d.com/t/stop-particle-velocity-via-treshold/4113/1 "2004-10-16T10:00:50Z")

</div>

hi, i am totaly new to MEL. i need to stop my particles to move after their speed falls under a certain tresholds, something like

if(velocity \< threshold) {   
 velocity = 0;  
}

now ... i really dont know where to put it, and how to actually script it, can anybody be so kind to tell me how i have to connect the script to my particles and what the code is going to look like? what I have so far doesnt work at all ... ☹  
thankyou

---

<div class="post-metadata">

### Author: ![failure](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/f/f08c70/32.png) [@failure](https://forum.highend3d.com/u/failure)
#### Post date: [October 16, 2004, 10:36am UTC](https://forum.highend3d.com/t/stop-particle-velocity-via-treshold/4113/2 "2004-10-16T10:36:08Z")

</div>

Open expression editor and create expression that will control per-particle velocity. Note that velocity is stored as a vector, you need to calculate length of that vector in order to get actual _speed_ of the particle.

$threshold = 1;  
vector $v = particleShape1.velocity;  
float $vAbs = sqrt ( $v.x \* $v.x + $v.y \* $v.y + $v.z \* $v.z );

if( $vAbs \< $threshold ){  
 particleShape1.velocity = \<\>;  
}

---

<div class="post-metadata">

### Author: ![mindsample](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/m/4da419/32.png) [@mindsample](https://forum.highend3d.com/u/mindsample)
#### Post date: [October 16, 2004, 10:48am UTC](https://forum.highend3d.com/t/stop-particle-velocity-via-treshold/4113/3 "2004-10-16T10:48:38Z")

</div>

thank you very much

---

<div class="post-metadata">

### Author: ![joojaa](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/j/5daacb/32.png) [@joojaa](https://forum.highend3d.com/u/joojaa)
#### Post date: [October 17, 2004, 1:55pm UTC](https://forum.highend3d.com/t/stop-particle-velocity-via-treshold/4113/4 "2004-10-17T13:55:12Z")

</div>

slight optimize

if( mag(particleShape1.velocity)\< $threshold ){  
 particleShape1.velocity = \<\>;  
}

---

<div class="post-metadata">

### Author: ![failure](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/f/f08c70/32.png) [@failure](https://forum.highend3d.com/u/failure)
#### Post date: [October 17, 2004, 2:42pm UTC](https://forum.highend3d.com/t/stop-particle-velocity-via-treshold/4113/5 "2004-10-17T14:42:22Z")

</div>

nice

---

<div class="post-metadata">

### Author: ![campbell](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/c/97f17d/32.png) [@campbell](https://forum.highend3d.com/u/campbell)
#### Post date: [October 21, 2004, 1:54am UTC](https://forum.highend3d.com/t/stop-particle-velocity-via-treshold/4113/6 "2004-10-21T01:54:18Z")

</div>

and another,

if(particleShape1.velocity \< $threshold )  
{

```
particleShape1.velocity = << 0, 0, 0 >>;
```

}

though, it might actually make it slower than directly instructing.

---

<div class="post-metadata">

### Author: ![joojaa](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/j/5daacb/32.png) [@joojaa](https://forum.highend3d.com/u/joojaa)
#### Post date: [October 21, 2004, 10:08am UTC](https://forum.highend3d.com/t/stop-particle-velocity-via-treshold/4113/7 "2004-10-21T10:08:21Z")

</div>

velocity is a vector value \< should not have anything to do with it but odes maya automaticaly convert it to magnitude? Oh vewll adding one mag is not all that much to do.
