• 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.

Precise unit positioning and distance?

Status
Not open for further replies.
Level 17
Joined
Sep 25, 2004
Messages
508
Long story short, I'm doing some animation experiments, and I'd like to make two units interact with each other. Things like shaking hands, passing an object to each other, that sort of stuff. As of now, I'm trying to make a "block punch and retaliate" move.

By using reference points I have a vague idea of where the contact point will be, but I can't find a way to precisely move and direct units in game, and thus I can't properly test the animations.

I've made a trigger to make the two units follow each other at map initialization (couldn't find a simple "move to X unit and stop at Y distance before it" function).
-Problem one, the actual distance they end up to seems to depend on their starting distance, and I can't predict it.
-Problem two, unit facing. I've made sure to include a command to force the two units to face each other (over 0.2 seconds) before attacking. But it doesn't seem to work always, and it's painfully obvious on certain angles.
-Third problem, it would be very useful to know the exact distance between the two units, is it possible to display it somehow?
-Last but not least, could someone give me some tips on how to manage the camera? I can't understand half of its property fields, let alone command it via triggers.
 

Attachments

  • animtestmap2.w3x
    757.1 KB · Views: 46
Level 20
Joined
Jul 14, 2011
Messages
3,213
1. Don't know
2. Check the "Unit Turn Speed" (something like that) field in the Object Editor and set it to max.
3. Check the collision size of the units. If both units have 16 collision size, they'll have 32 range distance between them.
4. There are several camera tutorials and explanations in thehelper.com and in this forum.
 
Level 17
Joined
Sep 25, 2004
Messages
508
2. Check the "Unit Turn Speed" (something like that) field in the Object Editor and set it to max.

It doesn't seem to make a difference, but thanks. After further testing, it looks like the game just doesn't bother to correct the unit direction if the target is very close to its front. Unfortunately, that small discrepancy is enough to mess up the whole effect.

3. Check the collision size of the units. If both units have 16 collision size, they'll have 32 range distance between them.

I don't think it's the case, if they really stopped so close to each other their selection circles would cross, wouldn't they? :)
 
Level 17
Joined
Sep 25, 2004
Messages
508
And I wasn't saying they are. But these particular selection circles have a diameter of 90, the two units alway stop way before their selection circles collide, and that means the total distance is well above 90. Unless I'm overlooking some embarassingly obvious detail.

Edit: it's closer to 70 than 90, but still, more than twice the collision size.
 
You can experiment with the Camera to learn about it's fields ;)

Just create a random camera, right click it in the window, and select "Edit Camera Properties", then select "Preview Values in Main Window"
Then, play around with them, and you'll catch on :D

To find unit collision, there are a few Jass snippets for that :eek:
Nestharus has one in the Jass section (I think)
Vexorian has one at wc3c.net too
 
Level 17
Joined
Sep 25, 2004
Messages
508
Yes, it'd be nice if I could have the time to learn it all, but I'm simply a poor, dumb amateur modeler who is just trying to pull off some half-decent animations. I barely understand GUI functions - let alone JASS - and given that free time is an extremely rare commodity nowadays, I'm not inclined to learn more than the strictly necessary to make this model work.

I can probably figure out how to calculate the units distance myself, but I really could use a hand on the rest.
 
-Problem one, the actual distance they end up to seems to depend on their starting distance, and I can't predict it.

Yeah, due to pathing movement and random occasional stops the movement becomes a bit unpredictable. The best way is to actually use a timer and "slide the unit" towards the point. (you set the x and y coordinates repeatedly) For more information on sliding, you can check out our spell section for samples.
Here is one example:
Knockback 2D

(knockbacks are the same as sliding concept-wise, just switch the angle to point in the opposite direction)

If you do it like this, it becomes more easier to predict the movement of units. (but it can be a bit of a hassle)
-Problem two, unit facing. I've made sure to include a command to force the two units to face each other (over 0.2 seconds) before attacking. But it doesn't seem to work always, and it's painfully obvious on certain angles.

Yeah unit facing is tricky because it doesn't time properly. There is a particular technique to make for instantaneous facing, if it helps:
http://www.wc3c.net/showthread.php?t=105830

However, if you want it for something like 0.2 seconds, you might be able to work something out. For example, you could reduce the time depending on facing angle difference. Or you can always just put 0 and hope for the best. It probably won't ever be perfect, but we can at least try to get as close to ideal as possible. ;) Maybe I'll run some tests eventually to help.

-Third problem, it would be very useful to know the exact distance between the two units, is it possible to display it somehow?

In GUI, you can just use:
  • Game - Display text ... to (All Players) for 60.00 seconds
Or something like that. Then in the string input, just choose the option "Conversion - Real to String", and from the real input, select "Distance between units". That is the easiest way to display it in GUI. The actual formula (which that field uses) is the distance formula:
distance%20formula.jpg


Where (x1, y1) are the initial coordinates and (x2, y2) are the final coordinates.

-Last but not least, could someone give me some tips on how to manage the camera? I can't understand half of its property fields, let alone command it via triggers.

Here is a tutorial I made for managing cameras, hopefully it will be useful:
http://www.hiveworkshop.com/forums/general-mapping-tutorials-278/cameras-160369/

It should explain all the fields and functions you would need to use. :)

Sorry that most of the questions are answered with somewhat unfavorable responses, I might make some samples eventually if I ever get back on my older computer.
 
Status
Not open for further replies.
Top