Hello, hello, hello.After having messed with angles in mugen, I couldn't help but waste my whole night thinking in normals, vectors and so on... I almost lost my sleep due to that... So, the first thing I did today as I got myself to my computer was to program a code for aimed projectiles based on the calculus of normalized vectors.So, here is the code :;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, 30Well, now I have to find the next funny formula to code in mugen... kisses.

I didn't even remember that Mugen had Exp and Ln. A simple ** operator would have been easier. QuoteWell, now I have to find the next funny formula to code in mugen... Since you've already done Bezier curves, may I suggest Hermite curves ?

Messatsu: You're welcome. It's good to know that someone is using an almost three years old code. Cybaster: Sounds like a challenge. I'll take a look on it as soon as I get motivated to work with mugen again.

Awesome, thanks, I was trying to make an aimed projectile for a while, thanksI would have never found it out, all those wierd stuff you used

Thanks for you efforts I think i'll be needing this, question though, what if the projectile has a point and you wanted the anim to face the correct angle, how would 1 go about coding that? (not a math guy in the slightest way ) edit: *nevermind I think you've covered it in a previous topic, you rock *

How exactly is the code used. Is it suppose to function like a sprite pointing in various directions with a gun to shoot in any given angle?