   Trajectories - With Friction
  I allready have a turret that can fire perfectly at the player WITHOUT friction. Example is here... http://iceflyin.com/hotlinked/lastStand.swfBut I need some help figuring out how to do it with friction.One of my options is to simply generate an array of projectile angles and distances at runtime.Also... Another brute force method is to use about 5 eliterations to shoot virtual projectiles nearer and nearer to the player, then finally actually firing the last one.[Edited by - iceflyin on June 3, 2006 5:48:24 PM]
  So to clarify, you are wanting to take into account air resistance?If that's the case, you'll have to choose a model of air resistance to follow (is the force directly proportaional to velocity or what?). Once you've decided on your model, then you can compensate for it.   ;  Kinda. The projectile only has air resistance applied on it's horizontal vector.Each frame... Horizontal Velocity is set to Horizontal Velocity *.98.In ActionScript pseudo-code that would look like...onEnterFrame{xVel *= .98;  /*Or it could be written like>>*/    xVel = xVel *.98.}So each frame it's slowing down like... 11.76-11.52-11.29-Etc...Basically... It's a cheap way to do it, but good enough for a webgame.   ;  So, does anyone know of anything that could help me create an AI turret that can aim correctly, with air resistance?[Edited by - iceflyin on June 3, 2006 5:19:26 PM];  Well, you'd prabably have to turn it into a parametric equation, like:************x = sx + ((1-power(f,t))/(1-f)) * svxy = sy + g * t*t + t*svy***********f=frictiong=gravityt= time/steps/framessx= starting x possy= starting y possvx= starting velocity of x, though you will not use this, but calculate it.svy= starting velocity of yobj=target point //solve for t, int the y equation, using the objects y pos.************t= (-svy+sqrt(svy*svy-4*g*(sy-objy)) )/(2*g)svx = (objx - sx)/(((1-power(f,t))/(1-f)))You can have the svy value anything you want, 0, negative positive.;  That parametric equation works nicely... Except I CAN'T get the aiming part to work right... If I just set svx and svy to 20 or something, the projectiles fire in nice arc's.But I seem to have a problem when trying to use your aiming formula. It seems to shoot the projectile at a speed of around 700 just above the tank, with Time=1 intially.Note: The language I am using uses reverse cartecian Y coordinates. svy = -35 would be upward at a velocity of 35. X coordiantes are normal.//This code only runs once, and variables are stored.var svy = -35;var t = (-svy+Math.sqrt(svy*svy-4*Gravity*(sy-_root.tank.point.gPoint.y)))/(2*Gravity);//With the inputs...//sy= 257.05, svy=35, Gravity=1, and Tank Postion PointY= 207.//The result is...//t = -1.49062774497388//Now the next part...var svx = (_root.tank.point.gPoint.x-sx)/(((1-Math.pow(Friction, Time))/(1-Friction)));//Tank Postion PointX =667.65, sx = -378, Friction = .999.svx... ends up at like... 600-700... LOL!At least this works nice... With reasonable svx and svy values.this._x = sx+((1-Math.pow(Friction, Time))/(1-Friction))*svx;this._y = sy+Gravity*Time*Time+Time*svy;[Edited by - iceflyin on June 3, 2006 7:16:29 AM];  Where did you get your equation for computing the angle? It seems incorrect. The equations I derived (and confirmed by other sources) are:angle = ½sin-1( rg/v2 ), or    angle = tan-1( k - sqrt( k2 - 1 ) ), k = v2/rg Take a look at this Wikipedia page: Trajectory of a projectileThe page also shows how to compute the angle in order to hit a target above or below you, and the effect of air resistance.   ;  I think I got that from hyperphysics.http://hyperphysics.phy-astr.gsu.edu/Hbase/traj.html#tracon   ;  Also, you might want to make your slowdown time dependent. It is probably contributing to your problems since your equation right now isn't time dependent and the horizontal amount will change based on how fast the computer is, making it impossible to aim accurately.   ;  Ummm... when i was testing the parametric equation, i used a reverse y coordinate, and found it to work independent of the reversed y coord. So maybe you should not invert the svy after you plug it in. The only time i found it not to work was when i was trying to simulate the gravity without using an x^2 curve, and the Wiki link seemed to cver the topic, including the vertical and horizontal friction. By the way, are you using &#106avascript? ActionScript?   