• 🏆 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!

Moving a unit to stay under another unit's origin.

Status
Not open for further replies.
Level 13
Joined
Oct 18, 2013
Messages
690
  • Set CasterLoc = (Position of Jounin[1])
  • Unit - Move DummyUnit instantly to CasterLoc
  • Custom script: call RemoveLocation(udg_CasterLoc)
This moves the unit fine, but it will never be at the base of the unit. Instead, it is placed a slight distance away from the position of the unit. Any help?
 
Level 13
Joined
Oct 18, 2013
Messages
690
Ye I turned collision off for the dummy unit and the movement was still awkward. I thought it was weird. I might have hosted old ver when it happened again though. I can check.
 
Level 13
Joined
Oct 18, 2013
Messages
690
Ah, Had to change the movement type to flying. Thanks


Errr.. Well this is odd. Now the effect will slide up on down for somereason. Do flying units just do that? How can I keep it on the ground?
 
  • Unit - Move Unit Instantly
^Using this automatically checks for pathing, that is not necessatily needed for you. You would have to deactive pathing, like explained already above.

An other solution would be just to use SetUnitX/Y to set change the unit's coordinate. These natives do not check for pathing, and it will always have the exactly same position of the targeted unit.

native SetUnitX takes unit whichUnit, real newX returns nothing
native SetUnitY takes unit whichUnit, real newY returns nothing

For getting the correct X/Y coordinates of the unit you can use:

constant native GetUnitX takes unit whichUnit returns real
constant native GetUnitY takes unit whichUnit returns real
 
Level 13
Joined
Oct 18, 2013
Messages
690
Thanks to you both XD I felt like I was going to use the setting cordinates to X's and Y's. I thought about trying it but decided to just hold off and ask THW :3

Edit:
Pm'd Icemanbo but didn't get a reply so ill just ask on here, How do i use this script? I've used set x and set y before, but i dont remember what i did. So:
constant native GetUnitX takes unit whichUnit returns real
Would this be valid?
constant native GetUnitX takes unit TempUnit returns TempReal

Then when using set unit i would replace the real with TempReal right? I think there are GUI actions for getting a unit's x and y.

Edit 2: Im using the Set X and Y properly, but when i use this, it does nothing. "native SetUnitX takes unit DummyUnit, real TempReal returns nothing " which tempreal being the x. so what gives?
 
Last edited:
I already replied your PM. But here is an example:
  • Set MainUnit = blabla
  • Set AttachUnit = xyzw
  • Custom script: call SetUnitX(udg_AttachUnit, GetUnitX(udg_MainUnit))
  • Custom script: call SetUnitY(udg_AttachUnit, GetUnitY(udg_MainUnit))
Of course you would not have to set these variables over, and over again the same value. But it shows how the custom script would look like.
 
Level 13
Joined
Oct 18, 2013
Messages
690
For some odd-ass reason, I still couldn't get this to work. I did something similar to what you did. I figured out how to do it (Err, well I thought I did, this doesn't do anything xP) and made this:
  • Set TempLoc = (Position of Jounin[1])
  • Set TempReal = (X of TempLoc)
  • Custom script: call SetUnitX(udg_SharinganUnit,udg_TempReal)
  • Set TempReal = (Y of TempLoc)
  • Custom script: call SetUnitY(udg_SharinganUnit,udg_TempReal)
  • Custom script: call RemoveLocation(udg_TempLoc)
I genuinely feel like I have not made an error .-. Idk. That trigger is turned on upon activation of the ability, variable SharinganUnit is set as (Last Created Unit) immediately after I create the unit via triggers. Please explain to me? :/
 
Level 13
Joined
Oct 18, 2013
Messages
690
^ Yeah I noticed that too. So hopefully changing the movement type to hover will counter that.

@Maker, Is the way I tried to do it wrong? That just won't work? I set Jounin on init, which may have been the issue considering I had too many things being initialized at init so the trigger wouldn't complete xD
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
@Maker, Is the way I tried to do it wrong? That just won't work? I set Jounin on init, which may have been the issue considering I had too many things being initialized at init so the trigger wouldn't complete xD

Your way is not wrong, but it is less efficient.

Setting too much stuff at map initialization can cause the initialization trigger to stop doing the actions.

Setting the initial sizes of several arrays to high values is one way to make that happen.

You can use Game - Display text message for debugging. Like displaying the name of the unit.
 
Level 13
Joined
Oct 18, 2013
Messages
690
Yep, I did that to confirm that was the issue. Alright, since my way is less efficient I have no problem with changing it. Maybe it will fix my issue xD If it does fix my issue I'd be rather perplexed, as its basically the same process o.o I'll get back to you and see.
 
Level 13
Joined
Oct 18, 2013
Messages
690
Bump: still doesn't work. Really odd. vars for caster and the dummy unit work. here is the loop that is supposed to move the dummy unit under the caster:

call SetUnitX(udg_SharinganUnit, GetUnitX(udg_Jounin[1]))
call SetUnitY(udg_SharinganUnit, GetUnitY(udg_Jounin[1]))
 
Level 14
Joined
Aug 30, 2004
Messages
909
So what is happening when the trigger fires? Does the unit move but not in the right place?

One problem I had that I never solved (though I did work around) was when I moved a unit with flying height it would sometimes pop up high (usually near cliffs). You could set the Sharingan unit's height to the flying height of the Jounin unit every time it moves.

Also, small point, if you reassign TempLoc you should destroy it first. In the trigger you posted earlier you assigned it, then assigned it again and then removed the leak. You'll need to remove the leak before each use. I would advise ignoring leaks for the moment though, until you get it working the way you want.

If you could post the full trigger we might be able to help more.
 
Level 13
Joined
Oct 18, 2013
Messages
690
Err, I can post trigger if you want. I posted all of the relevant information in my last post tbh.
  • Set CasterLoc = (Position of Jounin[1])
  • Unit - Create 1 DummySharingan for Neutral Passive at CasterLoc facing (0.00) degrees
  • Set SharinganUnit = (Last created unit)
  • Unit - Turn collision for SharinganUnit Off
  • Custom script: call RemoveLocation(udg_CasterLoc)
  • Trigger - Turn on SharinganDeact <gen>
  • Trigger - Turn on SharinganTrace <gen>
  • Trigger - Turn off (This trigger)
The whole CasterLoc at point of the caster will not be where I want it, because move unit takes pathing into account. I'm fine with that. SharinganTrace is the trigger with the actions aforementioned. I can also clear Location leaks fine, so don't worry yourself about it. :p
What happens: Idk how to exactly to word besides the dummy just doesn't move.
 
Level 14
Joined
Aug 30, 2004
Messages
909
The problem could be that you turned collision off after you placed it. So it already used its collision. After you turn off collision, move it back to CastLoc with the setUnitX and setUnitY Jass commands (or just use the GUI version and see if that works).
 
Level 13
Joined
Oct 18, 2013
Messages
690
What? Your reply didn't make any sense to me. I don't care if when it is created, that it is not spawned directly under the caster. What matters is that the loop works. the:
  • call SetUnitX(udg_SharinganUnit, GetUnitX(udg_Jounin[1]))
  • call SetUnitY(udg_SharinganUnit, GetUnitY(udg_Jounin[1]))
 
Level 14
Joined
Aug 30, 2004
Messages
909
It might help to see all the triggers together so we could follow them. The trigger you posted to me didn't move the unit at all; it just created it.

Did you try setting the unit's flying height to the flying height of the unit you want it to attach to?
 
Status
Not open for further replies.
Top