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

Two questions about unit movement

Status
Not open for further replies.
Level 9
Joined
Apr 19, 2011
Messages
447
Hi.

Well, I'm trying to make the two following things:

- I want a unit to move while playing a certain animation. How can I do it? I mean, I want the unit to move while playing, for example, the "Spell Channel" animation. But I'm unable to make it stop playing the "Walk" animation instead...
- I need a unit to follow a curved trayectory while facing a certain point. To be more concrete, I need a unit to follow a circle trayectory, but I need it to be constantly facing the player (it's for a boss).

Is there any way to solve any of these issues without using JASS? I'm a GUI user, so I'll be very happy if it can be done in GUI. If not, well... I'll have to wait until I learn JASS (I'm planning to). But I need to know if it can be done in GUI.

Thanks in advance.

Regards
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
About the animation: I don't know. You could just place the animation string on the spell (Channel) and order the unit to cast it.

About the movement: Yes, you need 2 Point variables. 1 For the center of the circle, and the other for the circle itself.

- You set a Real variable wich will be the degrees.
- You set "Point1 = *TheCenterOfYourCircle, which can be a unit, or anything*"
- Then Point2 (with polar projection) = Point1 offset by *distance between center and circle* towards *RealVariable*.
- Set RealVariable = RealVariable + 1 (If you want it to circle to the right, else place -1)
- Custom script: set udg_R1 = GetLocationX(udg_Point2)
- Custom script: set udg_R2 = GetLocationY(udg_Point2)
- Custom script: SetUnitPosition(udg_R1, udg_R2)
- Unit - Set unit facing to (Angle between Point1 and Point2). I'm not sure if you can directly make the unit face a Point, in which case, would be Point1.
- RemoveLoction(udg_Point1)
- RemoveLoction(udg_Point2)

<< Edit >> Forgot to say that locations stop unit animation. You would have to use X/Y Unit positioning. A fast fix for this would be having 2 real variables R1 and R2. Anyway, jassing it would be a lot easier and efficient. It's not hard at all.
 
Level 19
Joined
Feb 25, 2009
Messages
2,004
To move a unit while playing different animation you'll need to use coordinates instead of locations, since they do not cause the stop order from being executed.

You need to use those:
JASS:
local unit u
call SetUnitX(u , GetUnitX + Speed * Cos(GetUnitFacing(u) * 0.017453292))
call SetUnitY(u , GetUnitY + Speed * Sin(GetUnitFacing(u) * 0.017453292))
Please not that this is if the target is moving only in one direction, otherwise you'll need to customize the angle a bit.

To play a unit animation, use call SetUnitAnimation(unit, "spell channel")
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
- I want a unit to move while playing a certain animation. How can I do it? I mean, I want the unit to move while playing, for example, the "Spell Channel" animation. But I'm unable to make it stop playing the "Walk" animation instead...
Do you mean natural movement (Player order move) or movement via triggers ?

- I need a unit to follow a curved trayectory while facing a certain point. To be more concrete, I need a unit to follow a circle trayectory, but I need it to be constantly facing the player (it's for a boss).
Does the boss located at the center of the circle ?
 
Level 9
Joined
Apr 19, 2011
Messages
447
About the animation: I don't know. You could just place the animation string on the spell (Channel) and order the unit to cast it.

About the movement: Yes, you need 2 Point variables. 1 For the center of the circle, and the other for the circle itself.

- You set a Real variable wich will be the degrees.
- You set "Point1 = *TheCenterOfYourCircle, which can be a unit, or anything*"
- Then Point2 (with polar projection) = Point1 offset by *distance between center and circle* towards *RealVariable*.
- Set RealVariable = RealVariable + 1 (If you want it to circle to the right, else place -1)
- Custom script: set udg_R1 = GetLocationX(udg_Point2)
- Custom script: set udg_R2 = GetLocationY(udg_Point2)
- Custom script: SetUnitPosition(udg_R1, udg_R2)
- Unit - Set unit facing to (Angle between Point1 and Point2). I'm not sure if you can directly make the unit face a Point, in which case, would be Point1.
- RemoveLoction(udg_Point1)
- RemoveLoction(udg_Point2)

<< Edit >> Forgot to say that locations stop unit animation. You would have to use X/Y Unit positioning. A fast fix for this would be having 2 real variables R1 and R2. Anyway, jassing it would be a lot easier and efficient. It's not hard at all.
To move a unit while playing different animation you'll need to use coordinates instead of locations, since they do not cause the stop order from being executed.

You need to use those:
JASS:
local unit u
call SetUnitX(u , GetUnitX + Speed * Cos(GetUnitFacing(u) * 0.017453292))
call SetUnitY(u , GetUnitY + Speed * Sin(GetUnitFacing(u) * 0.017453292))
Please not that this is if the target is moving only in one direction, otherwise you'll need to customize the angle a bit.

To play a unit animation, use call SetUnitAnimation(unit, "spell channel")

Basicly both of you, Spartipilo and MortAr, are telling me to do the same thing, triggering the movement using X/Y and a bit of math.
I know that doing it in JASS would be much more efficient and easy, but as I said, I've not started yet at learning JASS. I'll give it a try in GUI, following your advice.

Do you mean natural movement (Player order move) or movement via triggers ?


Does the boss located at the center of the circle ?

If the movement is natural or triggered, it doesn't matter. I just want him to move.
And the center of the circle it's just the center of the boss battle arena. The boss is the one who moves around in a circle pattern, aleays facing the player, who will be wandering on the arena.

Regards
 
Level 9
Joined
Apr 19, 2011
Messages
447
About the animation: I don't know. You could just place the animation string on the spell (Channel) and order the unit to cast it.

About the movement: Yes, you need 2 Point variables. 1 For the center of the circle, and the other for the circle itself.

- You set a Real variable wich will be the degrees.
- You set "Point1 = *TheCenterOfYourCircle, which can be a unit, or anything*"
- Then Point2 (with polar projection) = Point1 offset by *distance between center and circle* towards *RealVariable*.
- Set RealVariable = RealVariable + 1 (If you want it to circle to the right, else place -1)
- Custom script: set udg_R1 = GetLocationX(udg_Point2)
- Custom script: set udg_R2 = GetLocationY(udg_Point2)
- Custom script: SetUnitPosition(udg_R1, udg_R2)
- Unit - Set unit facing to (Angle between Point1 and Point2). I'm not sure if you can directly make the unit face a Point, in which case, would be Point1.
- RemoveLoction(udg_Point1)
- RemoveLoction(udg_Point2)

<< Edit >> Forgot to say that locations stop unit animation. You would have to use X/Y Unit positioning. A fast fix for this would be having 2 real variables R1 and R2. Anyway, jassing it would be a lot easier and efficient. It's not hard at all.
To move a unit while playing different animation you'll need to use coordinates instead of locations, since they do not cause the stop order from being executed.

You need to use those:
JASS:
local unit u
call SetUnitX(u , GetUnitX + Speed * Cos(GetUnitFacing(u) * 0.017453292))
call SetUnitY(u , GetUnitY + Speed * Sin(GetUnitFacing(u) * 0.017453292))
Please not that this is if the target is moving only in one direction, otherwise you'll need to customize the angle a bit.

To play a unit animation, use call SetUnitAnimation(unit, "spell channel")

Basicly both of you, Spartipilo and MortAr, are telling me to do the same thing, triggering the movement using X/Y and a bit of math.
I know that doing it in JASS would be much more efficient and easy, but as I said, I've not started yet at learning JASS. I'll give it a try in GUI, following your advice.

Do you mean natural movement (Player order move) or movement via triggers ?


Does the boss located at the center of the circle ?

If the movement is natural or triggered, it doesn't matter. I just want the unit to move.
And the center of the circle it's just the center of the boss battle arena. The boss is the one who moves around in a circle pattern, always facing the player, who will be wandering on the arena.

Regards
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
If the movement is natural or triggered, it doesn't matter. I just want him to move.
Because if it's natural, it has to some advance triggering (cancel current move order and trigger the movement effect).

But if it's through trigger, it's easier because we can use SetUnitX/Y + SetUnitAnimation (move the unit + play the channel animation).

Here's a test map for the SetUnitX/Y + SetUnitAnimation.

And the center of the circle it's just the center of the boss battle arena. The boss is the one who moves around in a circle pattern, always facing the player, who will be wandering on the arena.
Your map is Single-player I presume ?
 

Attachments

  • test21.w3x
    12.5 KB · Views: 28
Level 9
Joined
Apr 19, 2011
Messages
447
Because if it's natural, it has to some advance triggering (cancel current move order and trigger the movement effect).

But if it's through trigger, it's easier because we can use SetUnitX/Y + SetUnitAnimation (move the unit + play the channel animation).

Here's a test map for the SetUnitX/Y + SetUnitAnimation.


Your map is Single-player I presume ?

I checked the test map, and it works just fine. I think I'll be able to make the rest of the unit movement on my own. Thank you!
I don't think I'll have problems with the math for the circle movement, but I'll post here if I have them.

Thanks to all of you for your help.

Note: I didn't know that units could move to the black borders of the map.:eekani:
I happens in your test map, though. When the unit reaches the black border, it passes through it...

Regards
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
Change the trigger to look like this;
  • Actions
    • Custom script: call SetUnitX(udg_u, GetUnitX(udg_u) + 5.00 * Cos(90.00 * bj_DEGTORAD))
    • Custom script: call SetUnitY(udg_u, GetUnitY(udg_u) + 5.00 * Sin(90.00 * bj_DEGTORAD))
    • Unit - Order u to Stop
Unit - Issue Order With No Target

Btw;
5.00 is the speed per 0.03 second (5 * 33 = 165 MS)
90.00 is the angle in which the unit is moving (with 0.00 being East and 90.00 being North).
 
Level 9
Joined
Apr 19, 2011
Messages
447
No... for the moment.
I want to face it on my own before calling for help. You know, I prefer to go and try to do things by myself, rather than asking others to do the work for me, unless I don't even know how to start, and that's not the case.

But I'll post if I have any problem.

Regards
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
You cannot use the X/Y moving with GUI.
Have you downloaded my test map on post #7 ?
EDIT: Do you mean GUI Action ? Lol.
Yes you cannot use the X/Y with GUI Action but you can use the X/Y with GUI Trigger

And thats not really JASS, I used the tags since its easier to paste it.
What is your definition of "JASS" ?
I used Custom script, that represents JASS enough.
 
Level 9
Joined
Apr 19, 2011
Messages
447
Just posting to say that I've completed the circular movement of the boss. It moves in a circular pattern, facing the hero, and playing the animation I need.
I want to thank all of you for your attention with this problem. Case solved.

Regards
 
Status
Not open for further replies.
Top