black.sheep
Active Member
- Reaction score
- 24
Hello, I would like to know how spells like wild axes work.(Mainly just the maths for controling the projectiles) and create a single projectile one.
JASS:// C is a point between A and B Cx = (Ax+Bx)/2a Cy = (Ay+By)/2 // gamma is the angle from A to B gamma = Atan2(By-Ay, Bx-Ax) // we use sin for x and cos for y to get a normal through point C // <b>curve</b> is a factor of curvature // zero means a perfect semicircle between A and B // any bigger number means bigger circle == smaller curve // negative curve == left side, positive curve == right side // D is some circle center on our normal Dx = Cx + curve*Sin(gamma) Dy = Cy + curve*Cos(gamma) // now that we have D we need angles from D to A, and from D to B // we will mark them as alpha and beta alpha = Atan2(Ay-Dy, Ax-Dx) beta = Atan2(By-Dy, Bx-Dx) // So out projectiles will move on circle sector, // center is D, starting angle is alpha, ending angle is beta // and radius is |DA| == |DB| == SquareRoot((Dx-Ax)^2+(Dy-Ay)^2) // alpha < angle < beta Mx = Dx + radius * Cos(angle) My = Dy + radius * Sin(angle) // So all you need to do is calculate in this order: // C, gamma, D, alpha, beta, radius // and then get M points by rotating angle from alpha to beta // This way you get one curve, to get 4 curves use different curve parameters // I recommend this curvatures: // +0.01 == positive zero // -0.01 == negative zero // +|AB|*0.87 == left side equilateral triangle ABD // -|AB|*0.87 == right side equilateral triangle ABD
Note: since all curves have different lengths angle speed (rotating from alpha to beta) should be the same for all of them to make sure all projectiles get to destination at the same time.
Happy coding :thup: