Pushing

SrL04

New Member
Reaction score
1
Hello, it's been awhile since I've been here :D

Ok let's get to the point, I'm making a trigger so that whenever a unit comes within like 75 radius of the box (a crate) then it will be pushed back a little bit. Like this, say you right click on the box right? The unit should move towards the box but when it gets to close it gets pushed back. I don't want the unit to stop after he gets pushed back, I want him to keep moving (even though he will keep moving backwards until he's 75 away from the box). I'm sure there is a way of doing this, but I just don't know how >< I've been wondering this for awhile now and I'd love to get some help :D Thank you in advance!
 

Corleone

New Member
Reaction score
44
Do you mean something like this?


Code:
Push
    Events
        Unit - A unit comes within 75.00 of No unit
    Conditions
    Actions
        For each (Integer A) from 1 to 10, do (Actions)
            Loop - Actions
                Unit - Move No unit instantly to ((Position of No unit) offset by 2.00 towards ((Facing of Triggering unit) - 180.00) degrees), facing (Facing of No unit) degrees

Note: It's not leak-free.
 

SrL04

New Member
Reaction score
1
But that only works one time, how can I make it so that it is every 0.01 seconds?
 
S

scythetleppo

Guest
you can add a command of

if the distance is still under my amount
run this trigger again
 
S

Sunny_D

Guest
the trigger of corleone works like following:

a unit comes within range of unit. then push it back 10 times - what would the unit make being outside of the 75-range again. now the unit can either go anywhere else, but when it comes again within range... you know what i mean? ;)
 
M

Mythic Fr0st

Guest
hmm

Variables

Loc, point, array 1
X, real, no array
Select, unit group, no array


Code:
Event
   - Every 0.75 seconds
Conditions
Actions
   - set Loc[0] = position of _box_
   - set Select = units in range of 500 of _box_
   - pick every unit in units in select and do actions
       loop
        - set Loc[1] = position of picked unit
        set X = distance between Loc[1] and Loc[0]
        if X less than or equal to 74
        then - set Loc[2] = Loc[0] offset by 75 - X towards facing of picked unit - 180
           - move instantly _box_ to Loc[2]
           - call RemoveLocation(udg_Loc[2])
        - call RemoveLocation(udg_Loc[1])
    - call RemoveLocation(udg_Loc[0])
    - call DestroyGroup(udg_Select)

Honestly, I prefer to load my "heroes" into an array, and refer to them with a Integer A / B statement, (cus its less laggy (unit groups always make lag))

(or use facing of _box_)

hope that works
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
> unit groups always make lag

That statement is way too general to hold...


I would recommend not to move the unit based on its facing.
Instead, move it towards angle from position of box to position of unit.
 
M

Mythic Fr0st

Guest
Well, In my maze maker, after cleaning all my leaks, I had plenty of lag from using unit groups (only a few) then after I changed to using Integer A loops, everything worked great... without lag, so my personal opinion is Unit Groups Make Lag, (specially when leaky)
 

SrL04

New Member
Reaction score
1
Yes, moving it towards angle from position of box to position of unit is what I had planned. Sadly, my WE keeps crashing everytime I save a map, or change something and test the map for some reason, so I'm re-installing it :D
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      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