Move Unit instantly from A - B walking Animated

Status
Not open for further replies.
Level 3
Joined
Oct 1, 2018
Messages
63
Hi guys.
This time i want to move a unit from one area to another area instantly to break through the limit of max speed (522).

I have ofcourse tried the surch function and google but the thing is instead of google those forum-searchings dont give me any usefull output. Google on the otherhand gave me simular trigger threads but they are all so complicated, like moving on circles and other stuff. I need an easy explanation of moving from a to b with highspeed.

I have 5 top and 5 bottom areas and the units should run one after another and not all at once. While the unit moves it should have the walk animation, until it reaches the bottom area and then the next unit, from top 2 should run to bottom 2. An explanation of 1 unit trigger would do. Who's gonna help me out?

Edit:
If it is possible please tell me how to make it full in GUI.
I really dont get this Jass stuff.

Edit 2:
I have come up with this Testmap. After many trys i finally managed to get the right angle to move downwards. But the animation doesnt show correctly. Why???
 
Last edited:
Simulating high-speed movement requires instant moving across small distances over a very small period of time. To successfully achieve that simulation, that action must be repeated over and over again.

Now, the reason why circles appear when dealing with this is because we want to get the angle by which we will displace a unit. So, to get the angle, we must project it from the end-point to the position of the unit. Note that the end-point is not equal to the destination point here.

At that point, we can now use the projection function in GUI, though it generates a new location for that.

From various sources (perhaps those which I cannot recall which are reliable or not), and by experience, a moving unit always overrides its' current animation by playing its' walk or run animation, depending on what its' current native move speed is. So, the only way to preserve walking animation is to work with the built-in movement system of the game.

Using the move function in GUI will always issue a stop order to the unit, along with path checking, but we don't want that, so these natives will be introduced to you:

JASS:
native SetUnitX(unit u, real r)
native SetUnitY(unit u, real r)

Unlike the GUI move function for units, these natives do not interrupt orders, and does not check pathability of the desired location.

Now, before we get to the triggers, we need to understand the need for variables in GUI (in other programming languages, global variables). Variables are things which store certain values at any given time, so it can still refer to some unit even after 500808 seconds have passed, as long as its' value hasn't been changed.

GUI variables are automatically prefixed with udg_, so when writing them in Custom Script, we have to manually add udg_ to the variable we want to use.

So, let's see the trigger which exemplifies the above:

  • Movement
  • Events
    • Time - Every 0.03 seconds of game-time.
  • Conditions
  • Actions
    • Comment: ---- Assume we have a unit variable udg_movingUnit and a point variable array udg_loc ----
    • Comment: ---- Assume we also have a real variable udg_moveSpeed ----
    • Comment: ---- udg_moveSpeed is the incremental boost to the movement speed of the unit. ----
    • Set loc[0] = GetUnitLocation(movingUnit)
    • Set loc[1] = (loc[0] projected (moveSpeed) towards an angle of (Facing angle of (movingUnit)))
    • Custom Script: call SetUnitX(udg_movingUnit, GetLocationX(loc[1]))
    • Custom Script: call SetUnitY(udg_movingUnit, GetLocationY(loc[1]))
    • Comment: ---- Now, we clean up the handles generated by the game.
    • Custom Script: call RemoveLocation(udg_loc[0])
    • Custom Script: call RemoveLocation(udg_loc[1])
Notice that it will keep displacing the unit, even when the unit stops. At that point, you can build up what logics are required for that movement system to work as you intend it. Note that it also does not cover the case when one enters a certain point, and gets displaced towards a target location (via A Unit Enters a region event).
 
Level 3
Joined
Oct 1, 2018
Messages
63
@MyPad
Thanks for the fast help.
I guess the loc (point) variables are with an array from 0-1.

-GetUnitLocation is the custom script order to adress the unit location.

But what does projection mean?
Is this the movement speed of the unit or is it the animation speed?

The rest can be made in GUI, eccept the Custom Scripts you showed me, am i right?

Edit:

I am german and my english is not the best of all. I try to give the best but sometimes i need to ask more and more.
 
Projecting in this context means mapping out the next point based on the displacement (distance) and the angle.

So, for a displacement of 100 and an angle of 90°, the unit would move 100 units north. For a displacement of 100 and an angle of 45°, the would be moved the 50✓2 units north and 50✓2 units east.

From there, you can see the fundamentals of sine and cosine appear in projection. Given an angle theta, and a displacement d, the next point would be mapped as follows:

JASS:
X = 100*Cos(theta*bj_degToRad)
Y = 100*Sin(theta*bj_degToRad)

As Sine and Cosine functions in the game accept radians for reals, the translation to radians is needed above.

For the GUI projection, the function returns an angle, instead of the radian that it should be.

As for the Custom Scripts, they are available in GUI for you to type.
 
Level 3
Joined
Oct 1, 2018
Messages
63
Thanks to you i finally understand this concept. The remove location funktions in this case should be above the others becouse the movement and animation cames beyound the variables and the trigger is periodic on until the unit enters the final area, where the movement trigger gets deaktivatet. Is that it? :)
 
Level 3
Joined
Oct 1, 2018
Messages
63
I have come this far. Currently i think i have problems with UnitX & UnitY. I dont know if i have to set up a point variable for both of them so i tried both ways and ended up with this error twice. This seems to be a bit tricky but i wont give up just now. I will continue this tomorrow.
 

Attachments

  • Movement.w3x
    13.2 KB · Views: 28
  • Trigger.jpg
    Trigger.jpg
    56.2 KB · Views: 52
  • Error.jpg
    Error.jpg
    55.3 KB · Views: 48
In the compiler error report, you're calling Set LocationX with the unit as a first parameter. The proper one is SetUnitX with respect to the manner of usage (or how the unit is handled).

A point, or a location in JASS, is basically a class object with two members, the X and the Y. We can interpret a location handle, thus, as an ordered pair, or one ordered pair in short.

Now, since we need to know the location of the unit, we associate one newly-created location handle to it. The other thing to know is the resulting end of that displacement, which is another ordered pair, so we project a certain location, generating a new location handle in the process.

Thus, we would need two location handles. Once we're done with that, we clean those up, and that is where RemoveLocation comes in. :)
 
Level 3
Joined
Oct 1, 2018
Messages
63
Hm... i have tried SetUnitX without any variable just as you discribed above and got the same error as when i later made the point variable LocationX and tried that way.

The first time i must have made an letter (or charakter) mistake/error so that the custom script didnt work. Or maybe its becouse my warcraft isnt updatet but i think i made an mistake. I will try this tomorrow. If i get that error again i will upload an full screenshot with the trigger, the Variables and the error all in one.
 
Level 3
Joined
Oct 1, 2018
Messages
63
This time i dont know what i did wrong. But it still does not work. I wasnt able to post it into one Screenshit, becouse i cannot save the map or activate the trigger while the variable window is opened. But it is all in this new map. This time i cannot even activate the trigger.

Sadly i cannot copy and paste triggers here becouse my pc doesnt have internet. I can only operate with my phone for now. This is going to change soon i hope. I already made ...how to say in english? Well i made an pact with o2. It cost me low cash but my soul. I dont even need it, so who cares? :)
 

Attachments

  • NewMovement.w3x
    13 KB · Views: 24
  • NewTrigger.jpg
    NewTrigger.jpg
    69 KB · Views: 25
  • NewError.jpg
    NewError.jpg
    155.3 KB · Views: 45
Last edited:
Level 3
Joined
Oct 1, 2018
Messages
63
i removed the space between call set Unitx
to call setUniX.

Error.
then i did it with , GetLocationX
to ,GetLocationX

Error. o_O

Edit:
Noticed an mistake by remove location. I used [ instead of ( andcorrected it. But that also didnt work. My custom scripts end all 4 in Error.

Edit2:
I forgot the _ in (udg_Var)
remove scripts are fixed now.

Edit3: iam so god damn dump!
-.-

Finally got it all to work.
here are the screenshot and the map.
 

Attachments

  • FinallyItWorks.jpg
    FinallyItWorks.jpg
    76.5 KB · Views: 24
  • NewMovement.w3x
    13.3 KB · Views: 25
Last edited:
Level 3
Joined
Oct 1, 2018
Messages
63
In the last step i have tried to make the unit play its walk animation. If done it happen before the periodic trigger moves the unit end ended the amimation when the unit reaches the target area of the walk trigger. I am able to get the right animation speed when i experiment a bitbwith that. But i noticed that moving the unit a distance of 25 each 0,01 seconds could be way to fast to play the animation correctly.

Sadly i need the distance of 25 per 0,01s, maybe even 50 per 0,01.

I need this trigger for my Slotmachine, so the units have to move that fast. Am i right guessing that the maximum animationspeed cant hold up with this movement speed? I mean in the end tze unit would play walk so fast that i couldnt even follow it. Isnt it so?

Edit:
Replaced the animation functions to the periodic trigger.
It did not work the first way. I am still experimenting with the animation speed.

maybe a trigger wich allows me to change the animation speed with arrowkeys could help me. I know how to built that, its no problem. When i let the unit walk
from area A-B, B-C, C-D and finally A-B i have somekind of a loop and than i can local the perfect animationspeed with arrowkeys and textmessages. Its quit simple, maybe it works for 25 distance per 0,01 seconds. Anyway anyone can local the perfect speed value for each unit using souch trigger. I will post it this evening no matter if i can get the right animationspeed for the distance of 25 per 0,0s.

The distance and animationspeed will be manipulateable with the arrowkeys and u will get the output from textmessages.

Edit 2:
Done already. Here is my SpeedTester map.
You can change the variables moveSpeed with up- and down-press, the animationSpeed with right- and left-press.

I still dont know if the animation function should be in the periodic movement triggers ore right before they start.

I have by the way found out, that if you change the moveSpeed to negative, the unit will walk backwords. I didn't know that before. It's so cool!!
 

Attachments

  • SpeedTester.w3x
    15.9 KB · Views: 27
Last edited:
Status
Not open for further replies.
Top