| 05-21-2009, 09:48 AM | #1 |
I want to make a spell that spirals units inwards to a target point. Is there a spiral formula that I can take hold of? I know how to do the spell but don't know the formula. |
| 05-21-2009, 10:07 AM | #2 |
You know how to use cos/sin to make a unit move in a circle, right? Just decrease the radius with each iteration. |
| 05-21-2009, 10:16 AM | #3 |
actually quite simple .... Easy, descriptive way to do it: imagine you got a line (vector) ... the one end is located at the center of the spiral ... Now you begin to periodically rotate that vector around the center... and move the position of the dummy unit to the other end of the vector ... Now you got a simple circle ... To get a spiral, just decrease the length of that vector over time. |
| 05-21-2009, 10:17 AM | #4 |
Okay. I'll give it a try. |
| 05-21-2009, 10:29 AM | #5 |
Model for a large class of spirals: Code:
x(t+dt) = x(t) + dt*v(t) v(t+dt) = v(t) - e*v(t)^p1 - dt*k*x(t)^p2 v(t): velocity e: Viscosity, try 0 to 1 k: strength of attraction, 1 dt: Time step, 0.05s p1: 1 to 2 p2: -2 for gravity, 1 for a spring |
| 05-21-2009, 10:40 AM | #6 |
@PipeDream that seems too complicated. Right now I have sort of gotten the hang of it but how do I detect whether a unit has completed a circle of radius x? |
| 05-21-2009, 10:43 AM | #7 |
Just keep track of the angle as you iterate it, once you're past 2pi radians or 360 degrees it's gone through one rotation. It doesn't matter what the radius was. |
