• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[General] How to Orbit a Unit Sideways?

Status
Not open for further replies.
That's gonna need some trigonometry to get the path to be perfectly circular, though the angle might need to be hardcoded. There's probably a better way of doing this, but so far it's the only method I've encountered. And don't even ask me how the fomula works, I just got it from Retera when he had some free time to help me out.

I said disregard this, damnit!

To have a smooth flying height, use this formula: LowestPoint + (1 + Cos*time) * (HighestPoint - LowestPoint) / 2

then steadily increase time by a value after setting the flying height. eg: Set time = (time + 4.00)

For a movement that goes from left to right, set your unit's X position with this formula:
(HighestPoint - LowestPoint) * (SinBJ*time) / 2

Setting your unit's Y position with do north-to-south.

Again, there's likely a better way of going at this so it's better to wait for the more math-savvy coders out there to help you out. That's just in case they don't.
 
Last edited:
This formula doesn't even make sense. Trigonometric functions take an argument. You can't just multiply the Cos with time simply because Cos is not a value but an operation. Also, you forget the orbit center is probably moving aswell.


It's as simple as that:
X = CenterX + Cos(bj_DEGTORAD*angle+(pi/2)) * radius * Cos(frequency*2*pi*time)
Y = CenterY + Sin(bj_DEGTORAD*angle+(pi/2)) * radius * Cos(frequency*2*pi*time)
Z = CenterZ + Sin(frequency*2*pi*time)*radius

X,Y,Z are the new coordinates of the orbiting unit.
CenterX,CenterY and CenterZ are the current coordinates of the orbit center.
Angle is the facing angle of your center unit in degrees.
Radius is the distance at which the orbiting unit will travel around the center.
Frequency is how often the unit travels a full circle per second.
Time is the time that passed. Increment this by your clock speed (-> 0.03 for a 0.03 second periodic timer).
 
When you say Angle is the facing angle of the center unit, does that imply that the vertical orbit will be perpendicular to it?
Yes. The orbiter will basicly spiral around the center when the center unit is moving, which is what I assumed was what the TO wanted. Not sure on that.

It will basicly look like this, just scripted (image from weep's frostbolt model):

2pqq6bs.gif
 
The only way I can think of doing it would be to tighten the left and right movement to something like a percentage of the diameter of the vertical orbit. Food for thought, I guess.
There are many ways to do that. But once stuff get's too complex, you should thing about importing one of the vector libraries anyway, which solve most of these issues elegantly.
 
Status
Not open for further replies.
Top