Jass sliding

FireBladesX

Eating my wings!
Reaction score
123
Is there a custom script (or two) that slide a unit according to it's facing angle and its custom value?


If I had to guess, it would be getting the cosine and sine of the angle * the custom value of the unit, and setting it to the unit's X and Y, but I don't know how to write that in jass, or if it's possible.

Or if it would be any better than doing the GUI function, point with polar offset.
 

Romek

Super Moderator
Reaction score
963
JASS:
function Expire takes nothing returns nothing
    local real x = GetUnitX(UNIT) // X of unit
    local real y = GetUnitY(UNIT) // Y of unit
    local real f = GetUnitFacing(UNIT) * bj_DEGTORAD // Angle of unit (Converted to Radians)
    // Change the '5' to alter the speed
    call SetUnitX(UNIT, x + 5 * Cos(f))
    call SetUnitY(UNIT, y + 5 * Sin(f))
endfunction

function Start takes nothing returns nothing
    call TimerStart(CreateTimer(), 0.05, true, function Expire)
    // You can also change the '0.05' to alter the speed / smoothness
endfunction


Something like that.
It's not MUI. "UNIT" is the unit it effects.
 

FireBladesX

Eating my wings!
Reaction score
123
Hrm, Ty regardless, but I was hoping for MUI.
I think I can make it work for MUI anyways, I dunno.


Do you know if using jass is better than GUI in this case?
 

Romek

Super Moderator
Reaction score
963
Hrm, Ty regardless, but I was hoping for MUI.
I think I can make it work for MUI anyways, I dunno.


Do you know if using jass is better than GUI in this case?
Using anything in JASS is better than GUI, in every case (Except maybe 1-line message display on init triggers)

To make it MUI, you'll need to learn how to use attachment systems such as ABC, HAIL, HSAS and TT.
 

FireBladesX

Eating my wings!
Reaction score
123
Hm, well, I was fooling around with custom scripts (I don't really know jass at all, just stealing stuff from random posts that I find), and I got this:
Code:
Custom script:   Custom script:   call SetUnitX(GetEnumUnit(), GetLocationX(udg_L2))
Custom script:   Custom script:   call SetUnitY(GetEnumUnit(), GetLocationY(udg_L2))
But, WE doesn't let me use it. What's wrong with it?
 

Romek

Super Moderator
Reaction score
963
Hm, well, I was fooling around with custom scripts (I don't really know jass at all, just stealing stuff from random posts that I find), and I got this:
Code:
Custom script:   Custom script:   call SetUnitX(GetEnumUnit(), GetLocationX(udg_L2))
Custom script:   Custom script:   call SetUnitY(GetEnumUnit(), GetLocationY(udg_L2))
But, WE doesn't let me use it. What's wrong with it?
Probably because you put "Custom Script:" inside the Custom Script.
 
General chit-chat
Help Users

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top