When I was browsing through some of my old shit, I found this piece of code...------------[piece of code]----------projectile (helper)....[State 0, ]type = AngleSettrigger1 = time = 0value = (atan((p2bodydist y-86)/(ifelse(facing = 1, enemy, pos X - Pos X , Pos X - enemy, Pos X)))*(-180/Pi))[State 0, ]type = AngleDrawtrigger1 = 1[State 8000, VelSet]type = VelSettrigger1 = time = 1x = (90-(atan((p2bodydist y)/(ifelse(facing = 1, enemy, pos X - Pos X , Pos X - enemy, Pos X)))*(180/Pi)))/10y = -(atan((p2bodydist y-86)/(ifelse(facing = 1, enemy, pos X - Pos X , Pos X - enemy, Pos X)))*(-180/Pi))/10....------------[/piece of code]----------I thought it was interesting. I haven't seen much characters needing auto aiming projectiles though.It's not really about the code, but about the formula. If you need more help or explenation on this, feel free to ask.

Useful for replicating Shadow Lady's Galaxy Missile perhaps? How would I make it multiple projectiles?

Shadow Lady, Sektor (or was it Cyrax?), etc...Bahn said, April 13, 2005, 03:21:06 amHow would I make it multiple projectiles?Add this code to any projectile the character creates.

Bahn said, April 13, 2005, 03:21:06 amHow would I make it multiple projectiles?By making multiple helpers and putting them all into the state with that code, perhaps? ???

^-- yes, the opposite of what I said, and it's better. Another method would be:SMEE IIRC said:Finds the X component of the vector Player, EnemyNear;Formula to find the components of a given vector AB;V(x) = B(x) - A(x);V(y) = B(y) - A(y)[State 1640, X]Type = VarSetTrigger1 = 1fvar(13) = (EnemyNear(0), Pos X - Pos X) * Facing ;Adjust the direction towards player facing;Finds the Y component of the vector Player, EnemyNear[State 1640, Y]Type = VarSettrigger1 = 1fvar(14) = (EnemyNear(0), pos Y - Pos Y);Finds the vector length;Formula of the length of a given vector AB;|AB| = (AB(x)^2 + AB(y)^2)^1/2[State 1640, Vector Length]Type = VarSettrigger1 = 1fvar(15) = Exp(0.5*ln((fvar(13) * fvar(13))+(fvar(14) * fvar(14))));To find the normalized vector one has to use ;the following formula:;Normal(AB) = V(AB)/|AB|;So, you divide the X and Y components of one vector by it's length;Obs: ;Normalized vector = The normalized vector of X is a vector in the same direction ;but with norm (length) 1.;Now that we have the normalized vector, we multiply it by the desired absolute velocity,;such as 5 pixels per frame.;Projectile[State 1640, Projectile]Type = Projectiletrigger1 = animelem = 2projanim = 1010projhitanim = 1020projremanim = 1020projremovetime = 240projpriority = 1projshadow = -1projsprpriority = 2projid = 1000offset = 0 ,-35velocity = (Fvar(13)/fvar(15)) * 5.0, (FVar(14)/fvar(15)) * 5.0 ;Normalizes the components;and multiply by the desired absolute velocity.attr = S, NPhitflag = MAFdamage = Floor(((3 + (3 * Random/1000.0)) * Fvar(28) + 0.5)), Floor(1 + (Random/1000.0) * Fvar(28) + 0.5)animtype = Hardguardflag = Mpausetime = 0,12sparkno = 1sparkxy = 26,0hitsound = 5, 2guardsound = 6, 1guard.sparkno = 40ground.type = Highground.velocity = -2.4ground.slidetime = 12ground.hittime = 12air.velocity = -2.4,-4.5air.fall = 1air.recover = 0ignorehitpause = 1getpower = 50, 75givepower = 20, 30

Yeah, SMEE posted that in this thread. That'll work if you'd rather use a Projectile than a Helper, and if you don't mind the projectile's animation not being rotated. Though that can be worked around, by including a range of angled animations in the AIR file, and choosing which anim to use based on the calculated angle.

Edit:Once the projectile is aimed, you shouldn't need to make seperate calculations to find the angle of rotation, just use it's velocity.http://www.mugenguild.com/forumx/index.php?topic=21303.0

Gotta add something to this. I recently tried to use this code to make a missile face p2 after spinning in place for a few seconds and found it to be badly inaccurate (missile facing down original sprite) came out in all sorts of wacky angles. Anyway i changed the sum around a lot for the angledraw and this has given me good results over 5 testsfvar(3) and var(2) have been set to p2dist Y and enemy, pos X respectivelyCode: [state blah]type = anglesettrigger1 = 1value = 90+(atan((fvar(3))/(ifelse(facing = 1, var(2) - Pos X , pos X - Var(2))))*(-180/Pi))Also found that it must be facing P2 if it wasn't it inverted the direction ie missiles back facing me.I think i'm gonna have to work on the velset bit too as that rocketed them off sideways at the speed of light.