• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Building gets displaced because of Unit, how to prevent?

Status
Not open for further replies.
Level 6
Joined
Mar 27, 2019
Messages
56
Currently facing a problem with my idea, following situation;

I want to make a Wall-System that creates a vertical/horizontal Wall in between 2 Wall-Points, however if I start to build the second Wall and my Builder stands in between those 2 Wall-Points the created vertical/horizontal Wall will be displaced due to the collision of the unit, any way to prevent that behaviour so that the Wall gets placed in that exact location without displacement? Also without hiding the Builder because there could be more Units nearby doing various tasks.

  • Build Wall
    • Events
      • Unit - A unit Begins construction
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Wall
    • Actions
      • Set VariableSet Temp_Point = (Position of (Constructing structure))
      • Set VariableSet Temp_Point2 = (Temp_Point offset by (256.00, 0.00))
      • Set VariableSet Temp_Point3 = (Temp_Point offset by (128.00, 0.00))
      • Set VariableSet Temp_Group = (Units within 1.00 of Temp_Point2 matching ((Unit-type of (Matching unit)) Equal to Wall).)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in Temp_Group) Greater than 0
        • Then - Actions
          • Unit - Create 1 Wall (VDummy) for (Owner of (Triggering unit)) at Temp_Point3 facing Default building facing degrees
          • -------- Just a Test --------
          • Unit - Hide (Last created unit)
          • Unit - Turn collision for (Last created unit) Off.
          • Unit - Move (Last created unit) instantly to Temp_Point3
          • Unit - Turn collision for (Last created unit) On.
          • Unit - Unhide (Last created unit)
        • Else - Actions
      • Custom script: call DestroyGroup(udg_Temp_Group)
      • Custom script: call RemoveLocation(udg_Temp_Point)
      • Custom script: call RemoveLocation(udg_Temp_Point2)
      • Custom script: call RemoveLocation(udg_Temp_Point3)
Should be a straight line but the Wall got displaced due to the Builders collision standing there.
ssss.png
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Although not ideal, a work around would be to try placing the wall multiple times over some period of time. The logic for this would be to try to place the wall, if the wall is displaced (blocked build site) then remove it and add the instance to a list. Every second or so iterate all instances in the list and try to place the walls again. Once the wall is successfully placed then remove the instance from the list.

Another approach would be to detect all units blocking the wall and then temporarily displace them using SetUnitX/Y until the wall is placed correctly. This might not be as reliable and would need to factor in unmoveable obstacles so might work well in addition to the above work around.
 
Level 6
Joined
Mar 27, 2019
Messages
56
Although not ideal, a work around would be to try placing the wall multiple times over some period of time. The logic for this would be to try to place the wall, if the wall is displaced (blocked build site) then remove it and add the instance to a list. Every second or so iterate all instances in the list and try to place the walls again. Once the wall is successfully placed then remove the instance from the list.

Another approach would be to detect all units blocking the wall and then temporarily displace them using SetUnitX/Y until the wall is placed correctly. This might not be as reliable and would need to factor in unmoveable obstacles so might work well in addition to the above work around.
The first one is nice, I could use a Dummy to detect if there is space and then place the Wall and delete the Dummy,
I found a somewhat good solution too, I used a Unit Dummy that has the Crow Transform Ability and it turns into the Structure via order thus not making it displaced, although in some occasions it does where the first method from you would become handy for this.
Second one would have been the easiest but I don't want to move units because of the order reset.

Thanks alot!
 
Status
Not open for further replies.
Top