# Ants movement (based on snow movement)

**URL:** <https://forum.kirupa.com/t/ants-movement-based-on-snow-movement/113875>\
**Category:** Uncategorized\
**Created:** [June 22, 2004, 4:57pm UTC](https://forum.kirupa.com/t/ants-movement-based-on-snow-movement/113875 "2004-06-22T16:57:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![exorxist](https://avatars.discourse-cdn.com/v4/letter/e/f4b2a3/32.png) [@exorxist](https://forum.kirupa.com/u/exorxist)\
**Post date:** [June 22, 2004, 4:57pm UTC](https://forum.kirupa.com/t/ants-movement-based-on-snow-movement/113875/1 "2004-06-22T16:57:48Z")

</div>

Hey! I have a question for those who think they can help and might have the time to do so. I wish to get the effect of ants scuttering across the screen or up a tree, I have not decided which direction yet. I started with the tutorial code for the snow effect from kirupa, and changed it around to fit the little vector ant I created. The way I have it now looks pretty good, but the movement is a little too fluid. They obviously move in sinusoidal paths bc the code tells them to. I have about 20 copies of the main obj, and they’re all a little different in size and specs (speed, transparency, etc) but what I was wondering was if there is any way I can change the code to make it a little more hectic, or erratic, not so fluid. If there is no way of doing so, it looks pretty good right now. If there is, however, I think it could look awesome. here’s the code I’m using for the object.

onClipEvent (load) {  
//stage  
movieWidth = 850;  
movieHeight = 50;

//mods for ants  
i = 1+Math.random()_5;  
k = 1.2_(-Math.PI)+Math.random()\*Math.PI;

//each ant diff  
this.\_xscale = this.\_yscale=38+Math.random()\*30;  
this.\_alpha = 75+Math.random()\*100;  
this.\_y = -10+Math.random()\*movieHeight;  
this.\_x = -10+Math.random()\*movieWidth;  
}  
onClipEvent (enterFrame) {  
rad += (k/70)\*Math.PI;  
this.\_y -= Math.cos(rad);  
this.\_x += i;  
if (this.\_x\>=movieWidth) {  
this.\_x = -3;  
}  
if ((this.\_y\>=movieHeight) || (this.\_y\<=0)) {  
this.\_y = -2+Math.random()\*movieHeight;  
this.\_x = -3;  
}  
}

(I apologize for posting the code without one of those code boxes ppl use, I do not know how to do that yet…)

Any help is greatly appreciated! I wanted to congratulate everyone here at kirupa for having a great community, and great help to those that need it. I am so glad to be a part of it.

Luke
