Move units to another unit w/o losing their formation

Eimtr

Member
Reaction score
1
[SOLVED] Move units to another unit w/o losing their formation

Looks like my last question with WE cause im soon done with it and war3. Then we will see how harder is SC2Editor is compared to sc2 beta.

I have a group of units in an army formation, close to each other. I want every 0.01 second to move them instantly to position of another unit. The problem is that if I Pick them and move them instantly they all are moved to the same point thus 10 units are pushed in1 point looking like one.

I want to move them to the position of the other unit instantly and keep their formation, not move them all at 1 point. But the object to which I'm moving them is also moveable so using a point on the map wont help as they always should be at the position of that other object that is also moving.

it's like I need to move them in the same way when you select more units in the editor and move them, they keep their formation/order
 

Accname

2D-Graphics enthusiast
Reaction score
1,463
instead of picking all units and issueing them the move order individually pick the whole group of them and issue that order to the group. but keep in mind you can only issue orders to groups of the size of 12 units or below.

Trigger:
  • Unit Group - Order (Units in (Playable map area)) to Move to (Center of (Playable map area))
 

Eimtr

Member
Reaction score
1
The thing is I dont want them to walk as this would look unrealistic. That's why Im using the 'Move instantly' not order to move and just remain with some distance between them, that is their formation. As I said, I need to keep their distance not just make them move at the same point.
 

Ashlebede

New Member
Reaction score
43
This is approximate ; they will keep their formation, but they might not end up exactly at the place where you want them to. Make sure there is plenty of space for them to land onto.

Trigger:
  • //Hand-written
    • -------- Requires two point-type variables, a unit group-type variable and 2 real-type variables --------
    • Set group = {Group}
    • Set point1 = Position of (Random unit from group)
    • Set point2 = {Target Point}
    • Set EstimatedDistance = Distance between point1 and point2
    • Set EstimatedAngle = Angle between point1 and point2
    • Custom Script : call RemoveLocation(udg_point1)
    • Custom Script : call RemoveLocation(udg_point2)
    • -------- If you want to destroy the group, use this line : --------
    • Custom Script : set bj_wantDestroyGroup = true
    • Unit Group - For each unit in group, do (Loop actions)
      • Loop - Actions
        • Set point1 = Position of (Picked unit)
        • Set point2 = point1 offset by EstimatedDistance towards EstimatedDegrees [Point with polar offset]
        • Unit - Move (Picked unit) to point2 (instantly)
        • Custom Script : call RemoveLocation(udg_point1)
        • Custom Script : call RemoveLocation(udg_point2)


Edit : Oh, and I saw you wanted to do that every .01 seconds. That is too much, most definitely. Maybe it's because my computer is really bad, but performance has always been a top priority to me. Those who want best effect for "frame-per-frame" animations use .03 delay. I usually use .04.
 

Eimtr

Member
Reaction score
1
I decided that it is better if they stand in a circle in some range from the Main unit. When I use the below triggers to move every 0.01 sec each of the units to form a circle around the main unit so that when the main is moving they also move - it works.

PROBLEMs:
- this trigger causes lag after the 3rd minute so I need an alternative of it that isnt laggy but you get what im trying to do
- Even if I make the circle and they stand attached to the main unit like that, whenever the Main unit rotates/turns on a direction, they do not rotate because they are placed at degrees in general but I need to make the degrees towards the facing of the Main unit,


Trigger:
  • Test2
    • Events
      • Time - Every 0.01 seconds of game time
    • Conditions
    • Actions
      • Unit - Move Marine 0003 <gen> instantly to ((Position of (Random unit from (Units of type Main Unit))) offset by 320.00 towards 30.00 degrees)
      • Unit - Move Terran Medic 0010 <gen> instantly to ((Position of (Random unit from (Units of type Main Unit))) offset by 320.00 towards 60.00 degrees)
      • Unit - Move Marine 0007 <gen> instantly to ((Position of (Random unit from (Units of type Main Unit))) offset by 320.00 towards 90.00 degrees)
      • Unit - Move Marine 0004 <gen> instantly to ((Position of (Random unit from (Units of type Main Unit))) offset by 320.00 towards 120.00 degrees)
      • Unit - Move Marine 0013 <gen> instantly to ((Position of (Random unit from (Units of type Main Unit))) offset by 320.00 towards 150.00 degrees)
      • Unit - Move Marine 0012 <gen> instantly to ((Position of (Random unit from (Units of type Main Unit))) offset by 320.00 towards 180.00 degrees)
      • Unit - Move Terran Medic 0009 <gen> instantly to ((Position of (Random unit from (Units of type Main Unit))) offset by 320.00 towards 210.00 degrees)
      • Unit - Move Marine 0006 <gen> instantly to ((Position of (Random unit from (Units of type Main Unit))) offset by 320.00 towards 240.00 degrees)
      • Unit - Move Terran Medic 0011 <gen> instantly to ((Position of (Random unit from (Units of type Main Unit))) offset by 320.00 towards 270.00 degrees)
      • Unit - Move Marine 0008 <gen> instantly to ((Position of (Random unit from (Units of type Main Unit))) offset by 320.00 towards 300.00 degrees)
      • Unit - Move Terran Medic 0015 <gen> instantly to ((Position of (Random unit from (Units of type Main Unit))) offset by 320.00 towards 330.00 degrees)
      • Unit - Move Marine 0014 <gen> instantly to ((Position of (Random unit from (Units of type Main Unit))) offset by 320.00 towards 360.00 degrees)
 

Ashlebede

New Member
Reaction score
43
Your trigger is leaking points. Replace a unit movement with :

Trigger:
  • //Hand-written
    • Set point1 = Position of {Unit}
    • Set point2 = point1 offset by {...}
    • Unit - Move {...}
    • Custom Script : call RemoveLocation(udg_point1)
    • Custom Script : call RemoveLocation(udg_point2)


That frees some memory space, allowing better long-term performance. Also, use .03 delay instead of .01, once again.
 

Eimtr

Member
Reaction score
1
This worked, thanks. But this solves the lag problem, at least now it seems to be OK. Problem 2 that has to do with the degree - now that I made the circle of units around the Main Unit, whenever I move the Main Unit on the map, it turns direction and when it turns direction, the circle of 12 units doesn't turn. So how do I make these degrees based on the Main unit's facing so that when it turns, the 12 units also turn side (not their facing but say a unit is at 12 0'clock and the front side of the Main unit too, when the front side of Main Unit turns left the unit at 12 o'clock should also turn left and the rest of the units based on the Main Unit facing)

Trigger:
  • Test
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set MainUnitPoint = (Position of (Random unit from (Units of type Domed Space Platform)))
      • Set MainUnitUnitPoint = (MainUnitPoint offset by 320.00 towards 30.00 degrees)
      • Unit - Move Marine 0003 <gen> instantly to MainUnitUnitPoint
      • Set MainUnitUnitPoint = (MainUnitPoint offset by 320.00 towards 60.00 degrees)
      • Unit - Move Marine 0004 <gen> instantly to MainUnitUnitPoint
      • Set MainUnitUnitPoint = (MainUnitPoint offset by 320.00 towards 90.00 degrees)
      • Unit - Move Marine 0006 <gen> instantly to MainUnitUnitPoint
      • Set MainUnitUnitPoint = (MainUnitPoint offset by 320.00 towards 120.00 degrees)
      • Unit - Move Marine 0007 <gen> instantly to MainUnitUnitPoint
      • Set MainUnitUnitPoint = (MainUnitPoint offset by 320.00 towards 150.00 degrees)
      • Unit - Move Marine 0008 <gen> instantly to MainUnitUnitPoint
      • Set MainUnitUnitPoint = (MainUnitPoint offset by 320.00 towards 180.00 degrees)
      • Unit - Move Marine 0012 <gen> instantly to MainUnitUnitPoint
      • Set MainUnitUnitPoint = (MainUnitPoint offset by 320.00 towards 210.00 degrees)
      • Unit - Move Marine 0013 <gen> instantly to MainUnitUnitPoint
      • Set MainUnitUnitPoint = (MainUnitPoint offset by 320.00 towards 240.00 degrees)
      • Unit - Move Marine 0014 <gen> instantly to MainUnitUnitPoint
      • Set MainUnitUnitPoint = (MainUnitPoint offset by 320.00 towards 270.00 degrees)
      • Unit - Move Terran Medic 0009 <gen> instantly to MainUnitUnitPoint
      • Set MainUnitUnitPoint = (MainUnitPoint offset by 320.00 towards 300.00 degrees)
      • Unit - Move Terran Medic 0010 <gen> instantly to MainUnitUnitPoint
      • Set MainUnitUnitPoint = (MainUnitPoint offset by 320.00 towards 330.00 degrees)
      • Unit - Move Terran Medic 0011 <gen> instantly to MainUnitUnitPoint
      • Set MainUnitUnitPoint = (MainUnitPoint offset by 320.00 towards 360.00 degrees)
      • Unit - Move Terran Medic 0015 <gen> instantly to MainUnitUnitPoint
      • Custom script: call RemoveLocation(udg_MainUnitPoint)
      • Custom script: call RemoveLocation(udg_MainUnitUnitPoint)
 

Ashlebede

New Member
Reaction score
43
One note : you have to remove the [ljass]MainUnitUnitPoint[/ljass] every time you give it a new value. The first few lines would become :

Trigger:
  • //Hand-written
    • Set MainUnitPoint = (Position of (Random unit from (Units of type Domed Space Platform)))
    • Set MainUnitUnitPoint = (MainUnitPoint offset by 320.00 towards 30.00 degrees)
    • Unit - Move Marine 0003 <gen> instantly to MainUnitUnitPoint
    • Custom Script : call RemoveLocation(udg_MainUnitUnitPoint)
    • Set MainUnitUnitPoint = (MainUnitPoint offset by 320.00 towards 60.00 degrees)
    • Unit - Move Marine 0004 <gen> instantly to MainUnitUnitPointSet
    • Custom Script : call RemoveLocation(udg_MainUnitUnitPoint)
    • Set MainUnitUnitPoint = (MainUnitPoint offset by 320.00 towards 90.00 degrees)
    • Unit - Move Marine 0006 <gen> instantly to MainUnitUnitPoint
    • Custom Script : call RemoveLocation(udg_MainUnitUnitPoint)
    • -------- And so on... --------


Just noticed there is also a unit group leak. It's about the same as with locations :

Trigger:
  • //Hand-written
    • Set MyUnitGroup = {...}
    • Set MainUnitPoint = (Position of (Random unit from MyUnitGroup))
    • Custom Script : call DestroyGroup(udg_MyUnitGroup)


And if I got what you mean, your angle should just depend on the facing of the main unit.

Trigger:
  • //Hand-written
    • Set MainUnitPoint = {...}
    • Set MainUnitFacing = Facing of ({Main unit})
    • Set MainUnitUnitPoint = (MainUnitPoint offset by 320.00 towards (MainUnitFacing+30.00) degrees)
    • -------- And so on... --------
 

Eimtr

Member
Reaction score
1
I decided to have them in a separate trigger for each unit as I am going to turn them off on some occassions and I did add those custom scripts:

Trigger:
  • DSPMedic011
    • Events
      • Time - Every 0.01 seconds of game time
    • Conditions
    • Actions
      • Set DSPGroup = (Units of type DSP)
      • Set DSP = (Position of (Random unit from DSPGroup))
      • Set DSPFacing = (Facing of (Random unit from DSPGroup))
      • Set DSPPoint = (DSP offset by 320.00 towards (DSPFacing + 330.00) degrees)
      • Unit - Move Terran Medic 0011 <gen> instantly to DSPPoint
      • Custom script: call DestroyGroup(udg_DSPGroup)
      • Custom script: call RemoveLocation(udg_DSP)
      • Custom script: call RemoveLocation(udg_DSPPoint)


etc. And yes I meant to rotate along with the main unit, so what you told me works. Thx for the help +rep
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top