I am trying to make an AI turret that not only fires at the player… But also adjusts for gravity, friction, and will use angles 45-90, or 45-0 based upon if I wan’t high angle shots, or low angle shots.
I would apreciate any anything on real gravity AI turrets in C++, Jscript, or even actionscript… But I doubt if it exists in actionscript!
Here are my tries so far…
Attempt 1
Attempt 2
dx/y = distances, x/ySpeed = Projectile speeds, .25 = projectile gravity, .99 = projectile friction
[COLOR=Magenta]//PROJECTILE CODE:[/COLOR]
xSpeed = xSpeed*friction;
ySpeed = ySpeed-gravity;
[COLOR=Magenta]//Attempt 1[/COLOR]
this.enemyBunkerTurret0._rotation = degrees+90-((((dx/xSpeed)*.99)+((dy/ySpeed)*.25))/2);
[COLOR=Magenta]//Attempt 2[/COLOR]
this.enemyBunkerTurret0._rotation = degrees+ 90+(xSpeed*Math.sin(dx*Math.PI/360)*.99 + ySpeed*Math.cos(dy*Math.PI/360)*.25);
I really am starting to get desprate here… LOL!