• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Quick, simple problem

Status
Not open for further replies.
Level 3
Joined
Jun 14, 2007
Messages
56
Hi gents.

Simple problem here;
I want to have a unit slowly rotate, at a constant speed, to face the way the controlling player clicks

The idea is that it is not a one off thing, rather something that will constantly update in the main looping trigger.

the looped script cannot be something as simple as this:
  • Unit - Make unit face point over 2.0 seconds
as it wouldnt be a constant rate of change, a full 180 degree turn would take as long as a simple 5 degree turn


furthermore it cannot be something like this:
JASS:
local real direction
local real angle = AngleBetweenPoints(unit, target)
if angle > direction  then
     set direction = direction + 10
else 
     set direction = direction - 10
endif
call UnitFaceAngle(unit, direction)
as angles are clamped between 0 and 360. If you are facing angle 10 and you click angle 350 then it would go all the way around turning left, instead of turning right which is closest.

So what is an easy, clean way of making a unit choose to either start rotating left or rotating right to eventually be facing the same direction as has been ordered?

Help is much appreciated.
Matt
 
Level 3
Joined
Jun 14, 2007
Messages
56
I had a look at the 'while' action. Interesting. A few questions

1) How does it differ from "if/then"?
2) How would you use it, specifically?
 
Level 1
Joined
Feb 24, 2010
Messages
62
'While' is very simple: as long as the requirement is still met, it'll repeat those actions.

  • Variable - Set i = 0
  • General - While (Conditions) are true, do (Actions)
    • Conditions
      • i != 5
    • Actions
      • Variable - Modify i: + 1
      • UI - Display (Text(i)) for (All players) to Subtitle area
      • General - Wait 1.0 Real Time seconds
Alright, so in this example, the actions will be repeated as long as 'i != 5', and each time, it'll display the value of 'i' and then wait a second, until 'i == 5'.

Usage depends on it, I (for now) hardly use it, but that's because I'm more used to 'For each integer' combined with 'If - Then - Else', while this should be faster. :p
 
Status
Not open for further replies.
Top