1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. The 18th Icon Contest is ON! Choose any ingame unit and give him/her Hero abilities. Good luck to all.
    Dismiss Notice
  4. The Secrets of Warcraft 3 have revealed interesting works. The RESULTS for Abelhawk's Mini-Mapping Contest #15 have come out!
    Dismiss Notice
  5. Contestants are to create a scene set in the Stone Age. Come and see what you can come up with. We wish you the best of luck!
    Dismiss Notice
  6. Colour outside the lines! Techtree Contest #13 is a go. The contest is optionally paired.
    Dismiss Notice
  7. Night Rider gained several songs for his journey. The poll for the 12th Music Contest has started. Check it out!
    Dismiss Notice
  8. Greetings cerebrates, our Swarm needs new spawners that will have numerous children. Join the HIVE's 31st Modeling Contest - Spawners and Spawned! The contest is optionally paired.
    Dismiss Notice
  9. Join other hivers in a friendly concept-art contest. The contestants have to create a genie coming out of its container. We wish you the best of luck!
    Dismiss Notice
  10. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Help Rotating Spawned Units

Discussion in 'Requests' started by Bubo, Jul 14, 2019.

  1. Bubo

    Bubo

    Joined:
    Jul 14, 2019
    Messages:
    8
    Resources:
    0
    Resources:
    0
    Im looking for help regarding rotating units from one area to an other where they need to keep their position but be able to rotate how they are positioned.
    I've looked around on the internet and haven't found a solution and I've also experimented around for a long time now and cant figure it out so if anyone have any tips, suggestions or solutions please help me.

    Heres the issue in more detail
    Picture: Imgur

    So I've managed to keep the positioning when they keep their rotation (From Area 1 to Area 2)
    But I need help figuring out how to rotate them and keeping their rotation as shown in the pictures.

    So it needs to be able to rotate all the different directions (up, down, left and right)

    So when the units will be teleported I will make a variable holding the rotation and the mathematics begind it so it can be used without making a long long trigger.

    So if anyone can help me with this it will make my day and make it possible to make my map shine
    because right now it gets unfair when your backline fights someones frontline :(

    Thanks in advance!
     
  2. Pyrogasm

    Pyrogasm

    Joined:
    Feb 27, 2007
    Messages:
    2,663
    Resources:
    1
    Spells:
    1
    Resources:
    1
    Making autochess are you? The solution is very simple, presuming your arena is actually square (not rectangular like your picture).

    Find the center point of the arena, then for each unit calculate:
    • Distance from center
    • Angle from center to unit
    • Unit facing
    I would save these in set of parallel arrays. Then when you need to spawn the units in an arena, simply add 0, 90, 180, or 270 to both the angles (depending on which way they should face). Spawn units using polar projection from the center of the arena using the original distances but modified angles.
     
  3. Bubo

    Bubo

    Joined:
    Jul 14, 2019
    Messages:
    8
    Resources:
    0
    Resources:
    0
    Sadly im not doing autchess, hope there will be some good ones til reforge comes out.
    But youre correct they are squares.

    Do you think you could do it and show how its done or how its built in the trigger editor?
     
    Last edited: Jul 15, 2019
  4. Bubo

    Bubo

    Joined:
    Jul 14, 2019
    Messages:
    8
    Resources:
    0
    Resources:
    0
    I've tried a little bit but im juggling it with my real life studies and more so it haven't worked out yet.
    I've managed to keep the positioning and teleport them around and all that but still no clue on the rotation part.
     
  5. Pyrogasm

    Pyrogasm

    Joined:
    Feb 27, 2007
    Messages:
    2,663
    Resources:
    1
    Spells:
    1
    Resources:
    1
    • Set Center = (Center of Region1 <gen>)
    • Set UnitCount = 0
    • Custom script: set bj_wantDestroyGroup = true
    • Unit Group - Pick every unit in (Units in Region1 <gen>) and do (Actions)
      • Loop - Actions
        • Set UnitCount = UnitCount + 1
        • Set UnitU[UnitCount] = Picked Unit //or you can store the unit-type if you're recreating them instead of teleporting them
        • Set UnitF[UnitCount] = (Facing of (Picked Unit))
        • Set UnitP = (Position of (Picked Unit))
        • Set UnitD[UnitCount] = (Distance between Center and UnitP)
        • Set UnitA[UnitCount] = (Angle from Center to UnitP)
        • Custom script: call RemoveLocation(udg_UnitP)
    • Set TurnAngle = 180.00 //choose 90 (E) 180 (S) 270 (W) according to which way it should face; I assumed units started facing North
    • For each (Integer A) from 1 to UnitCount do (Actions)
      • Loop - Actions
        • Set UnitP = (Center offset by UnitD[UnitCount] towards (UnitA[UnitCount] + TurnAngle) degrees)
        • Unit - Move UnitU[UnitCount] instantly to UnitP, facing (UnitF[UnitCount] + TurnAngle) degrees
        • Custom script: call RemoveLocation(udg_UnitP)
    • Custom script: call RemoveLocation(udg_Center)
     
  6. Bubo

    Bubo

    Joined:
    Jul 14, 2019
    Messages:
    8
    Resources:
    0
    Resources:
    0
    Thank you, I will give this a try next week!
    if it works out I will add you to the credits, thanks so much buddy!
     
  7. Bubo

    Bubo

    Joined:
    Jul 14, 2019
    Messages:
    8
    Resources:
    0
    Resources:
    0
    At the line "Set UnitU[UnitCount] = Picked Unit" How would I be able to set it and store the type for each induvidual unit. So far its working out but then all units that gets "copied" over turns into one type thats set there. Im used to add it all to a Unit group and then spawn them iduvidual from the group. mind sharing how its done with unit-types?
     
  8. Pyrogasm

    Pyrogasm

    Joined:
    Feb 27, 2007
    Messages:
    2,663
    Resources:
    1
    Spells:
    1
    Resources:
    1
    Made an error, should have used Int A in the lower loop.

    Set Play = The Player however you get that
    ...
    Set UnitT[UnitCount] = (Unit type of (Picked Unit))
    ...
    Unit - Create 1 UnitT[(Integer A)] for Play at UnitP facing (UnitF[(Integer A)] + TurnAngle) degrees
     
  9. Bubo

    Bubo

    Joined:
    Jul 14, 2019
    Messages:
    8
    Resources:
    0
    Resources:
    0
    I tried it and its doing the trick BUT I added a picture explaining the new problem.
     

    Attached Files:

    • a.PNG
      a.PNG
      File size:
      1.2 MB
      Views:
      18
  10. Pyrogasm

    Pyrogasm

    Joined:
    Feb 27, 2007
    Messages:
    2,663
    Resources:
    1
    Spells:
    1
    Resources:
    1
    I again made an error and wrote to use UnitP. Obviously you should not do that since it's not an indexed array storing the data. Instead create the unit at CenterPoint offset by UnitD[(Int A)] towards UnitA[(Int A)] degrees.
     
  11. Bubo

    Bubo

    Joined:
    Jul 14, 2019
    Messages:
    8
    Resources:
    0
    Resources:
    0
    Hey been some time. I got it figured out and did what you wrote but now the issue is that when they teleport they dont keep their position.
    When I change where CenterPoint is they still dont spawn/create at the locaiton I want them to they just endup getting spawned in the same area they are copied from. and when I try it with a different region/variable they dont keep their position.

    Do you know what im doing wrong?

    P.S Sorry for late reply, been busy with real life stuff.
     
  12. ThisPOT

    ThisPOT

    Joined:
    Feb 23, 2009
    Messages:
    561
    Resources:
    3
    Spells:
    3
    Resources:
    3
    Howdy Bubo,

    Can you link your test map or your trigger? What Pyro suggested is the way to do it, so you probably have an error somewhere, but I can't tell unless I take a look at it ^^...

    PS: I've done this exact system for one of my maps where your troops are teleported from your base but retain formation (can even re-angle them while keeping formation - like, everyone face right instead of bot, but keep formation)
     
  13. Bubo

    Bubo

    Joined:
    Jul 14, 2019
    Messages:
    8
    Resources:
    0
    Resources:
    0
    imgur
    I cant find anything wrong with it, maybe I've been staring too long for it so it all seems fine.
     
  14. ThisPOT

    ThisPOT

    Joined:
    Feb 23, 2009
    Messages:
    561
    Resources:
    3
    Spells:
    3
    Resources:
    3
    Use the [ TRIGGER ] (copy triggers as text here) [ /TRIGGER ] block next time ^^

    Ok I'm gonna do this a bit differently, it will be faster and simpler I believe, though essentially exactly the same.

    PS: I would create new units every time and hide the team while it's "battling" personally, so that you don't need to save any info (just create new units instead of moving them). But that's only if the players keep their units between battles.

    PPS: Pyro's way is better (with arrays) only if you NEED to keep those infos, if you don't need to store anything this method is faster and processes faster too.

    • Go
      • Events
        • Player - Player 1 (Red) types a chat message containing a as An exact match
      • Conditions
      • Actions
        • -------- --- --------
        • -------- We are going to calculate all points from the center point --------
        • -------- For both figuring out the initial formation and to place the units --------
        • Set Point_A = (Center of Region 1 <gen>)
        • Set Point_B = (Center of Region 2 <gen>)
        • -------- --- --------
        • Set Group = (Units in Region 1 <gen>)
        • Unit Group - Pick every unit in Group and do (Actions)
          • Loop - Actions
            • Set Point_C = (Position of (Picked unit))
            • Set Point_D = (Point_B offset by (Distance between Point_A and Point_C) towards ((Angle from Point_A to Point_C) - 90.00) degrees)
            • -------- Point_D also contains all the necessary math, like figuring out the angle and distance --------
            • -------- We remove 90 degrees to make a sharp right and rotate the whole formation --------
            • Unit - Move (Picked unit) instantly to Point_D, facing ((Facing of (Picked unit)) - 90.00) degrees
            • -------- --- --------
            • Custom script: call RemoveLocation(udg_Point_C)
            • Custom script: call RemoveLocation(udg_Point_D)
        • Custom script: call DestroyGroup(udg_Group)
        • -------- --- --------
        • Custom script: call RemoveLocation(udg_Point_A)
        • Custom script: call RemoveLocation(udg_Point_B)
     

    Attached Files:

    Last edited: Aug 15, 2019 at 5:15 PM