| 12-29-2009, 03:34 AM | #1 |
Basically I created a center unit with a bunch of other units around it. I want all the units around the center unit to move, keep their correct distance, and rotate with the center unit. How would I do this? |
| 12-29-2009, 04:08 AM | #2 |
You didn't put much effort into your post. You should be more specific about whether you already know anything about how to approach the problem or not. Do you code in GUI or JASS? Do you know anything about polar offsets? Anyway, you need to use a periodic timer to update the positions of all of the surrounding units. You can figure out the positions each unit should have by doing a polar offset in the direction the central unit is facing for the first unit, then incrementing the angle by (360/number of surrounding units) for the next unit, and so on. |
| 12-29-2009, 05:05 AM | #3 | |||
Quote:
Quote:
Quote:
|
| 12-29-2009, 06:38 AM | #4 |
It'd be easy if you didn't want to make them rotate along with the unit's facing. You could just use a constant x/y offset (that you calculate initially using polar projections) for each of the surrounding units. But since you would need to rotate the offset vectors, you wind up needing to do Cos/Sin stuff anyway. |
| 12-29-2009, 11:29 AM | #5 | |
Quote:
|
| 12-30-2009, 03:31 AM | #6 | |
Quote:
|
| 01-04-2010, 12:22 AM | #7 |
He is referring to the trigonometric functions you'll need to perform what you want. Look the JASS function PolarProjectionBJ to understand how it works. You give it a location, it'll return a location that is projected forward by the amount you want, in the angle you want. Example: some location = GetLocationOfYourUnit() PolarProjection(location, 50, towards angle) What he was saying is that it doesn't always have to be calculated since they are always in the same distance. I whipped up a demo map for you, so you can see a more practical way of how it works. NOTE: You cannot use this in your map. It leaks locations, and you'll have to optimize it. I just did it in 5 minutes so you can have an idea. |
