Does anyone know where I can get a projectile formula? The one that can take the distance between two MC’s, and then fire a projectile with a set velocity at the correct angle and hit the other MC?
Hmmm… Trying to figure this out.
Projectile Motion - Trig/Phys
[URL=“http://64.233.179.104/search?q=cache:V6heatVJE14J:www.cs.iupui.edu/~aharris/flash/fg2r11/fg2r11AH.doc+actionscript+formula+turret+tracking+arc&hl=en&gl=us&ct=clnk&cd=1&client=firefox-a”]Projectile Motion - Vectors
I’m not doing this corectly… So far my idea has been to calculate the impact point, and change it based upon if it’s greater or less than distance between the player and the turret.
I need to be able to track in full 2d, not 1d… Plus that method seems inefficent.
I think I found it… But I g2g for a bit…
[FONT=Courier New][SIZE=2] dx = _root.targetMC - gun._x;[/SIZE][/FONT]
[FONT=Courier New][SIZE=2] dy = _root.targetMC - gun._y;[/SIZE][/FONT]
[FONT=Courier New][SIZE=2] radians = Math.atan(dy/dx);[/SIZE][/FONT]
[FONT=Courier New][SIZE=2] degrees = radians * 180 / Math.PI;[/SIZE][/FONT]
[FONT=Courier New][SIZE=2] degrees += 90;[/SIZE][/FONT]
[FONT=Courier New][SIZE=2] if (dx <0) {[/SIZE][/FONT]
[FONT=Courier New][SIZE=2] degrees -=180;[/SIZE][/FONT]
[FONT=Courier New][SIZE=2] } // end if[/SIZE][/FONT]
[FONT=Courier New][SIZE=2] gun.dir = degrees;[/SIZE][/FONT]
[FONT=Courier New][SIZE=2] gun._rotation = degrees;[/SIZE][/FONT]
[FONT=Courier New][SIZE=2] //charge is distance from gun to target divided by 10[/SIZE][/FONT]
[FONT=Courier New][SIZE=2] distance = Math.sqrt(dx*dx + dy*dy);[/SIZE][/FONT]
[FONT=Courier New][SIZE=2] gun.charge = distance / 10;[/SIZE][/FONT]
[FONT=Courier New][SIZE=2]} // end followMouse[/SIZE][/FONT]
Also… Total newb question.
Whats the difference between these two, and why do classes and prototypes seem to need the second one?
thisVariable = 10;
var thisVariable = 10;