HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Using Set Unit X/Y

08-17-2007, 06:30 AM#1
Tide-Arc Ephemera
I'm planning on using set unit X/Y because it doesn't disrupt orders and can be used for some interesting sliding functions, as well as being able to interfere with pathing normalities.

A few questions...

1. I forgot what the unit set X/Y function is... what is it? (Don't need the radiants or degrees function yet, just physical X/Y's)

2. Would I be able to use this to find points and move to with set X/Y?
Trigger:
Actions
Set ReaUnitXY[1] = (X of (Position of (Target unit of ability being cast)))
Set ReaUnitXY[2] = (Y of (Position of (Target unit of ability being cast)))
Custom script: set Unit X/Y thingy here...

3. Would I be able to use polar offset with something similar, like this?
Actions
Trigger:
Actions
Set ReaUnitXY[1] = (X of ((Position of (Triggering unit)) offset by 10.00 towards (Facing of (Triggering unit)) degrees))
Set ReaUnitXY[2] = (Y of ((Position of (Triggering unit)) offset by 10.00 towards (Facing of (Triggering unit)) degrees))
Custom script: set Unit X/Y thingy here...

4. If the two above methods work, do they leak?

That's it for now, and thanks ahead!
08-17-2007, 06:48 AM#2
PipeDream
1. common.j will answer this question with a quick search. The answer is.. drumroll please... SetUnitX, SetUnitY
2. Yes
3. Yes
4. Yes. Convert to custom script. Look up the type of each function called. Does it return a handle? If so, you probably have to clean up after it. In this case you need to destroy the locations you create with "Position of"
08-17-2007, 06:53 AM#3
Tide-Arc Ephemera
I'm not good with finding things... where's the common.j?

So... if I use the small method I am using now, I can remove the memory leaks by setting a point, then extracting the X/Y off it?
08-17-2007, 07:21 AM#4
Ammorth
The polar projection leaks 2 points, the position of the unit, and then the projected point.

Quote:
Originally Posted by Tide-Arc Ephemera
I'm not good with finding things... where's the common.j?

Its one of the main map scripts and is located in the main mpqs as well as on some websites ( http://www.wc3jass.com/viewforum.php?f=20 )

Quote:
Originally Posted by Tide-Arc Ephemera
So... if I use the small method I am using now, I can remove the memory leaks by setting a point, then extracting the X/Y off it?

yes. It would be more efficient to only get the point once and then use the x and y value of the same point, without recreating the point.
08-17-2007, 07:32 AM#5
Tide-Arc Ephemera
Collapse JASS:
native          SetUnitY            takes unit whichUnit, real newY returns nothing
native          SetUnitX            takes unit whichUnit, real newX returns nothing
That's what it says... and that appears to be for JASS... as in the examples, how would I use this in GUI? Somebody told me, but I have since forgot...

EDIT! I just realised... would I swap out whichUnit with udg_MyUnitVariable and newX and newY with my real variables?
08-17-2007, 04:43 PM#6
fps-doug
ya, your newx newy variables are the new x and y that you want the unit to be at.

And whichunit can be the global variable udg_myguy .
08-17-2007, 05:22 PM#7
Dark.Revenant
Wait, so you use SetUnitX like this?
Trigger:
Custom Script - native SetUnitX takes unit udg_TempProjectile, real udg_TempX returns nothing
I was doing it like this:
Trigger:
Custom Script - call SetUnitX(udg_TempProjectile, udg_TempX)
It didn't move the model itself, but the shadow moved correctly, heh.

Edit: Nope, I figured out the hard way that using it like that doesn't work either.
08-17-2007, 08:11 PM#8
fps-doug
umm I think I heard somewhere if the unit has no movespeed only the shadow will move.
08-17-2007, 08:18 PM#9
Rising_Dusk
Quote:
umm I think I heard somewhere if the unit has no movespeed only the shadow will move.
The physical model itself remains at the same spot but the shadow and selection circle move correctly.
The unit needs at least 1MS.

Trigger:
Custom Script - call SetUnitX(udg_TempProjectile, udg_TempX)
This is the correct usage.
08-17-2007, 10:25 PM#10
Tide-Arc Ephemera
I'll be using this for spells, so mostly it will be effecting heroes 'n' units, not missiles 'n' stuff.

+Rep for all (who helped)!
09-26-2007, 03:16 PM#11
BOESERTEDDY
Hm can anybody help me? I'm trying to use that function, to creat different things like a waterslide, or wind ect...
So I want that all units that enter a certain area are constantly moved to the right, but not interrupted.
(I also tried to do it with other ways (bit more in jass) but never managed to get no error... and i also happened to delete those tries...(stupid me))


Trigger:
WaterslideDo Kopieren
Collapse Event
Zeit - Every 0.04 seconds of game time
Condition
Collapse Action
Collapse Unitgroup - Pick every unit in SlideWater and do (Actions)
Collapse Schleifen - Aktionen
Set TempProjectile = (Picked unit)
Set tempPoint[0] = (Position of (Picked unit))
Set TempX = ((X of tempPoint[0]) + 15.00)
Custom script: call RemoveLocation(udg_tempPoint[0])
Custom script: call SetUnitX(udg_TempProjectile, udg_TempX)

If I try this, it says variablename expected (at the setunitx-function)

Help would be really appreciated ;-D
09-26-2007, 03:36 PM#12
TheSecretArts
A, Dont hijack threads when the problem has been solved.
B, Your problem would be solved by using Handle Vars (easy way), or caster system, read a tutorial about it.