How to move a unit in a line...

Status
Not open for further replies.
Level 6
Joined
Oct 10, 2009
Messages
1,426
Problem solved by:
darwin & MortAr-
I want to move a unit (target of a spell) towards another (the caster) over time.
I was wondering how to do this because I don't know, but I think it involves math, which I find highly annoying.


33342686.jpg


+rep will be rewarded.
Also, if you'd like to teach me what the hell things like "cos" do, that would be great.
(if any are needed)
 
Last edited:
This may or may not help, but here's what I'd do:

Make a variable for the caster and the target unit. When the spell is cast, assign the target and the caster to their variables, then turn on a trigger that is initially off. Call the Trigger "Repeated move" or something like that.

Event - periodic, every .1 seconds
condition- none
action-
Move Target instantly to position of Target offset by 10 toward the angle between Target and Caster.

If Distance between Target and Caster < 100, turn off this trigger.

Sorry I don't have all the words right, but that should be the general logic. Hopefully it'll get you started. If it's too fast or too slow you can change the "10" above.
 
  • Trigger
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set loc[1] = (CASTER)
      • Set loc[2] = (TARGET)
      • Set angle = (Angle from loc[2] to loc[1])
      • Set loc[3] = (loc[2] offset by 10.00 towards angle degrees)
      • Unit - Move TARGET instantly to loc[3]
      • Set distance = (Distance between loc[1] and loc[2])
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • distance Less than or equal to 100.00
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
      • Custom script: call RemoveLocation (udg_loc[1])
      • Custom script: call RemoveLocation (udg_loc[2])
      • Custom script: call RemoveLocation (udg_loc[3])
 

Attachments

Status
Not open for further replies.
Back
Top