Given coordinates a hero's position (x1,y1), I'd like to command a unit to travel to a target point (x2, y2). I'd like this unit to travel an arc path instead of a straight line.
Kueken's boomerang outro is an example of something like the trajectory I have in mind.
If I'd like the unit to travel in a line instead of an arc, I can simply issue a move order to the unit and have the unit travel directly to the target point. However, I'd like the unit to travel in an arc. Could anyone describe or create an example function?
Presumably the unit would be issued persistent move orders targeting (x,y) coordinates that update over time until the unit reaches the target point. I've been issuing an order targeting a point offset by degrees and distance.
You know how I know you're gay? You have hots beta.
basically you just order the unit to move to a point with a polar offset from another unit...... if you want it to be based off the source units facing angle then you have to work that into the polar offset.
polar off set means you want a point that is at a specific angle from another point.
The angles used are the basic 360 N,S,E,W of the map..... getting used to the directions of these might be confusing at first
KageNinpo = SN
DialogLeaderboard & TeamSort
yeah, my problem is developing an equation with proper iterations so that the unit travels from point a to point b along the equation's path.
while this probably seems elementary to some, i need some help accomplishing this task.
suppose i want a unit to travel 10 spaces in a particular direction. however, i want the unit to travel along an arc instead of a direct line.
how could i write a function to achieve this goal without the certainty that the unit will arrive at a target point?
i can obtain the distance from one point to the other using a standard distance formula. however, this formula only prescribes the distance if the line is a straight line. i'd like the unit to travel in an arc, and therein my problems begin.
the unit's speed is 7, if it helps. and i'd like the arc to look something like the arc of the boomerang (along its initial journey). i realize i appear to be trolling because this is relatively basic math (to those in the programming field). however, i need some help solving this quandry.
unfortunately it seems that movers are only applied for launch missile effects. so when i apply a mover to a unit, and the unit isn't launched with a launch missile effect, the unit is unable to move.
(interestingly it is possible to launch a unit with a launch missile effect and apply a mover to the unit. it's not necessary to flag the unit as a missile for this purpose).
Please explain what your actually trying to accomplish..... using a unit for what your doing may not be what you actually want to do.
If your trying to make something rotate around a unit.... your probably better off using effects and actors.
Or you can move a unit around another unit by just using a move triggers... ordering the unit to actually move will more then likely not accomplish what your looking for.
Please give a detailed account of what your end product is spose to be.
I could make a unit move in an arc around another unit..... but it wouldnt be very effecient. And Id have to putz around with it quite a while but basically...... you can order the unit to move to a specifc point when it gets there order it to the next point...... but when the source unit moves...... the rotating unit wouldnt move it with....for it to reach its next point it would need to run in straight lines to get to the next itteratied point.
If you are going to use triggers to give movement commands to a unit then I know how to help you.
If you are trying to do this in the data editor with actors and movers then I don't know the capabilities of that kind of stuff.
Here's my current custom abilities demo map.
The ability in question is "Hellzone Grenade."
The initial launch phase is an arc trajectory followed by a second motion phase that is a linear trajectory. I'd like to unify these two trajectories into one arced trajectory. You can see my current trigger launches the missile along an arced trajectory and then resorts to a linear trajectory that guides the missile to its destination.
I'd like to unify these two motion phases into one motion phase. While this could be easily accomplished with movers, perhaps you can see from the map why triggers are preferable in this instance. So I need an equation that issues a move order to a unit such that the mover order is continually update from point A to point B.
Point A is the initial position of the missile (Tassadar's position). Point B is the destination point of the missile (a random point specified by a polar offset). It's possible to return the value of the destination point in coordinates (x,y) so that I'm sending the missile from:
Point A (x1,y1) -> Point B (x2,y2). And so I need an equation that issues updating move orders to the unit so that the unit travels from point A to point B in an arc like the boomerang's outro.
Can you order the projectile to move to its position offset by x toward some angle between the projectile's facing and the angle between the projectile and the target? The math would be something like [(projectile facing) + (((angle between projectile and target) - (projectile facing)) / 2)]. Give this order every 0.10 seconds or so and the projectile should arc toward the target from whatever angle it's launched from.
Malum Ruina: SC2Mapster
Eternal Exile: SC2Mapster
Spine Crawler Madness: SC2Mapster
Xeno Crisis: SC2Mapster
OK, well what I would do is establish a set of points (I'm going to assume 5 points) along a curve. When you issue a command to a unit you can set an option to "after existing orders" which means that you can get it to follow from one point to the next. I'm going to have to assume you have a GOOD understanding of trigonometry, how to use arrays and hopefully understand polar co-ordinate systems otherwise this will be very hard to explain.
Forget about unit locations, angles and all that complicated stuff! Just think about the shape you want on a simple x-y plane. Like a graph where x goes from 0-1 and y is the shape of the curve.
Have one array called curve which is of type "point" with size = 5.
Set all the x values to [0.2, 0.4, 0.6, 0.8, 1]
set all the y values so that it forms the curve that you want. for example:
[0,0,0,0,0] is a straight line,
curve = [1, -1, 1, -1, 0] would be a zig-zag,
curve = [0.4, 0.489, 0.489, 0.4, 0] is a semicircle,
curve = [0.587, 0.951, 0.951, 0.587, 0] is the top part of a sine wave and
curve = [0.25, 0.5, 0.7, 0.65, 0] is just some numbers that I came up with that I think would look like a boomerang curve.
now that we have the shape of the curve defined we want to make it the right size for our situation. which means that it needs to be stretched or shrunk depending on the distance between Tasadar and his target.
so create a function called scale which takes a point P, a real A and returns a point P*A
function scale(point P, real A)
x = x value of P;
y = y value of P;
return (x*A, y*A);
we need to get our curve to be oriented in the right direction. Rotation of a point by an angle is complex, feel free to bang your head on a wall looking up the proof... but the equation is:
x' = x*cos(a) - y*sin(a)
y' = x*cos(a) + y*sin(a)
where x and y are the coordinates of the point before the rotation and x' and y' are the points after rotation.
for example the point (1, 0) rotated 0.5*pi (or 90 degrees) is (0, 1)
wikipedia article: http://en.wikipedia.org/wiki/Rotation_%28mathematics%29
function rotate(point P, real angle)
x = x value of P;
y = y value of P;
new_x = x*cos(angle) - y*sin(angle);
new_y = x*cos(angle) + y*sin(angle);
return (new_x, new_y)
the curve is in the right direction and right size but needs to be in the right place
translate(point P, point offset)
x1 = x value of P;
y1 = y value of P;
x2 = x value of offset;
y2 = y value of offset;
return ((x1 + x2), (y1 + y2));
set curve as a global variable with the desired shape of the curve
distance = distance between Tasadar and target;
angle = angle between Tasadar and target;
i = 0;
while(i < 5)
next_point = scale(curve[i], distance);
next_point = rotate(next_point, angle);
next_point = translate(next_point, position of Tasadar);
order target to move to next_point after existing orders;
i = i + 1;
This will cause the projectile to arc towards its target in the desired tragectory. In the example above there are only 5 points along the curve but you can make it as detailed as you want to make it a very smooth path.
WOW, ok that took a lot longer to explain how to do than I thought it would. I guess it's like most things, once you know how to do it it sounds easy until you have to explain it to someone else and only then do you realize how complicated it is. Hopefully you understood me most of the way through
You must login to post a comment. Don't have an account? Register to get one!