   Random fly movement
  Hi guys I'm here because I'm not sure how to solve this problem and I want to see if someone before me have already done something similar. I need to move an object like a fly(bee, flying insect) in a 2d space.I'm looking for an algorithm that simulate this behavior. I have looked for some days in internet but I can't fine something useful for my problem.My thought for an algorithm are:- chose random an angle between 0° and 360°- move for a random length the fly - chose randomly if is time to change direction or to go straightrepeat for everI like this approach but I want to see what people have done(I'm sure someone have already done this) to find some more clues I didn't see.I love to be well documented before starting something special....and this work should be special Thank you everybody for your helpbest regardsEnrico Bottani   
  Sounds like a good start, although I would personally base it on splines with randomly selected points to simulate the smooth curved movement of an insect in flight; you could accomplish the same thing using a simple steering behaviour that slowly curves around towards each selected objective point, with the bonus that if you use steering, you can throw in flocking or obstacle avoidance or whatever pretty easily.   ;  Actually, the flight of flies in particular (this doesn't apply to bees or other insects) is pretty much a sequence of straight paths with very sharp turns called saccades. These are typically about 90 degrees and happen over less than 50 ms, so it's probably not worth smoothing them.I saw a fascinating talk once about a study of what triggers the saccades. The visual system of the fly is simple enough that one can actually understand a lot of what it's doing, and what it's doing is performing flow estimation on the moving images. If the right side of the image seems to grow in size, a saccade to the left is triggered, and simmetrically with the left side and siccadas to the right. This simple behavior allows the fly to avoid obstacles: If you are flying through a corridor and you are getting too close to the left wall, turning right will make you avoid it. Another interesting behavior is that if the image seems to be growing in front of the fly, it may trigger a saccade to either side, but it sometimes triggers landing. This way the fly makes some sort of random path until it lands somewhere. From that point on the fly will try to taste the thing it landed on and I am not sure what else, because the talk only dealt with flight. I believe this link is basically the same thing I heard in the talk, or at least it has a large intersection.   ;  Sigh. If I wasn't in a hotel, late at night, after flying, and before a long day at UPenn, I would be able to write up a decent approach to this.Maybe towards the weekend. In the meantime, you are in good hands.   ;  Keep it simple... like ApochPiQ suggested, go with splines or simple steering behaviors.  Unless you're aiming to create a fly flight simulator, I don't think you have too much time to waste on this.   ;  That's cool, alvaro.With this saccade idea, beit, it seems pretty easy to produce something good-looking.  You'd define three regions in front of the fly -- straight-ahead, left-ahead, and right-ahead -- and when an object enters one you'd trigger the corresponding saccade (with left/right/land chosen with certain probabilities in the "straight-ahead" case).  Throw in a tiny bit of process noise (every timestep, make the fly do a very small random turn in one direction or the other) so you don't end up in weird limit cycles due to the only-90-degree turns, and you're done.My original thought had been to refer you to Craig Reynold's old  Wander behavior page, but I think the method I sketched in the previous paragraph, based closely on alvaro's post, will give more flylike behavior.   ;  First I want to thanks everybody for the help, I found so many incredible topic,thank you ApochPiQ for the steering behavior solution, really interesting and you remember me splines, lost in my brain after two year out of the university thank you alvaro for your fascinating story about fly movement, saccades and also the link you posted was amazing. I read that article and I found it amazing.and finally thank you very much Emergent because you point me in the right direction. I think that I will try to develop the wander steering behavior. I found it really nice and I also have an idea how to develop it. And it fit completely with my project. I will not need to  avoid obstacles or the behave exactly how a fly. Thank you another time for your time and your help When I finish to develop the algorithm if someone is interested I will post it best regardsEnrico   ;  In addition modelling the flight behaviour of insects, you might want to look into add other interesting elements, such as seeking behaviour. For example, looking for a food source, or a warm sunny spot to rest. Flies often sit in the light in mornings to warm up.I also noticed that flies can be also territorial. I observed a large blue bottle fly sun bathing, which routinely chased off other flies and insects that were flying too close. Even more interesting, the blue bottle actually remembered where it sat, and landed back almost at the exact spot to continue sun bathing. Was very interesting to watch. You should be able to model some of this using seeking behaviour techniques.   ;  I've had a lot of success with swarming AI.  You don't need very sophisticated individual AI if you can have multiples of them in a "swarm".  The swarm looks absolutely great and very real in an eerie kind of way.What I've done in my game is when a group of enemies is in swarm mode, they just steer towards the center point which is calculated from the average of all the individuals positions with the addition of an additional anchor point which can be moved around.  Each individual has a heading, a velocity, and can either be thrusting or not.  If they are within a certain radius of the current swarm point, then they stop thrusting and just keep coasting according to their current velocity, but when they leave that threshold radius, they start thrusting again and turn to face the swarm point.tl;dr If you want to show a convincing fly, you might try having several flies swarming together.   