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

3D Pathing v2.0

This bundle is marked as useful / simple. Simplicity is bliss, low effort and/or may contain minor bugs.
  • Like
Reactions: deepstrasz
3D PATHING
What this does:
It detects the terrain height at a unit and compares it to it's last point. If the point is so much bigger then the last point the unit was at it makes the unit go back to its original point. This also includes falling. If a unit jumps off a too steep of a point, the unit will fall.


Made this with an indexing system to increase efficiency. (Must ONLY use Bribe's indexer for this)
Reduced the code quite a bit

Triggers
  • Set Things
    • Events
      • Map initialization
      • Game - UnitIndexEvent becomes Equal to 1.00
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • UnitIndexEvent Not equal to 1.00
        • Then - Actions
          • Set Gravity = 30.00
          • Set AloudHeight = 20.00
        • Else - Actions
          • Custom script: if UnitAddAbility(udg_UDexUnits[udg_UDex],'Arav') then
          • Custom script: call UnitRemoveAbility(udg_UDexUnits[udg_UDex],'Arav')
          • Custom script: endif
          • Set TempPoint = (Position of UDexUnits[UDex])
          • Custom script: set udg_TempReal = GetLocationZ(udg_TempPoint)
          • Custom script: call RemoveLocation(udg_TempPoint)
          • Set LastHeight[UDex] = TempReal
  • Pathing 3D
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in (Playable map area) matching (UnitMoving[(Custom value of (Matching unit))] Equal to True)) and do (Actions)
        • Loop - Actions
          • Set TempUnit = (Picked unit)
          • Set TempInteger = (Custom value of TempUnit)
          • Set TempPoint = (Position of TempUnit)
          • Set TempPoint2 = (Point(LastUnitMovingX[TempInteger], LastUnitMovingY[TempInteger]))
          • Custom script: set udg_TempReal = GetLocationZ(udg_TempPoint)
          • Set TempReal2 = (TempReal - LastHeight[TempInteger])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Distance between TempPoint and TempPoint2) Less than 100.00
              • (TempReal2 - (Current flying height of TempUnit)) Greater than AloudHeight
            • Then - Actions
              • Custom script: call RemoveLocation(udg_TempPoint2)
              • Custom script: call SetUnitX (udg_TempUnit,udg_LastUnitMovingX[udg_TempInteger])
              • Custom script: call SetUnitY (udg_TempUnit,udg_LastUnitMovingY[udg_TempInteger])
              • Set UnitMovingX[TempInteger] = LastUnitMovingX[TempInteger]
              • Set UnitMovingY[TempInteger] = LastUnitMovingY[TempInteger]
            • Else - Actions
              • Custom script: call RemoveLocation(udg_TempPoint2)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (-1.00 x TempReal2) Greater than AloudHeight
                • Then - Actions
                  • Animation - Change TempUnit flying height to ((Current flying height of TempUnit) - TempReal2) at 0.00
                • Else - Actions
              • Set LastHeight[TempInteger] = TempReal
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Current flying height of TempUnit) Greater than ((Default flying height of TempUnit) + 1.00)
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Falling[TempInteger] Equal to False
                    • Then - Actions
                      • Set FallRate[TempInteger] = Gravity
                      • Set TempPoint2 = (Point(LastUnitMovingX[TempInteger], LastUnitMovingY[TempInteger]))
                      • Set FallAngle[TempInteger] = (Angle from TempPoint2 to TempPoint)
                      • Custom script: call RemoveLocation(udg_TempPoint2)
                      • Unit - Set TempUnit movement speed to 0.00
                    • Else - Actions
                      • Set FallRate[TempInteger] = (FallRate[TempInteger] + (Gravity x 0.03))
                  • Set Falling[TempInteger] = True
                  • Set TempPoint2 = (TempPoint offset by Velocity[TempInteger] towards FallAngle[TempInteger] degrees)
                  • Custom script: call SetUnitX (udg_TempUnit, GetLocationX (udg_TempPoint2))
                  • Custom script: call SetUnitY (udg_TempUnit, GetLocationY (udg_TempPoint2))
                  • Custom script: call RemoveLocation(udg_TempPoint2)
                  • Animation - Change TempUnit flying height to ((Current flying height of TempUnit) - FallRate[TempInteger]) at 0.00
                • Else - Actions
                  • Unit - Set TempUnit movement speed to (Default movement speed of TempUnit)
                  • Set TempPoint2 = (Point(LastUnitMovingX[TempInteger], LastUnitMovingY[TempInteger]))
                  • Set Velocity[TempInteger] = (Distance between TempPoint and TempPoint2)
                  • Custom script: call RemoveLocation(udg_TempPoint2)
                  • Set Falling[TempInteger] = False
                  • Animation - Change TempUnit flying height to (Default flying height of TempUnit) at 0.00
          • Custom script: call RemoveLocation(udg_TempPoint)
Please don't ask me to make this have units go under platforms. As this is completely impossible.

Keywords:
Falling, moving, pathing, collision, height, gravity, physics
Contents

3D pathing (Map)

Reviews
12th Dec 2015 IcemanBo: Too long as NeedsFix. Rejected. Units bug at edges of platforms, the go up and down very rapidly making them blink Units can also get stuck on edges of platforms I used a flying unit and it somehow lost its selection...

Moderator

M

Moderator

12th Dec 2015
IcemanBo: Too long as NeedsFix. Rejected.

Reviewed by Maker, 3D Pathing v2.0, 11th Jan 2012

Units bug at edges of platforms, the go up and down very rapidly making them blink
Units can also get stuck on edges of platforms
I used a flying unit and it somehow lost its selection circle
Maybe flying units don't need to fall
You might not want to pick structures
I think you should use a group you don't destroy, add/remove units to/from it


Maker, 2.5D Pathing, 18th Oct 2011

Instead of picking every unit in the map, you should do a group managing system. No you're picking structures and dead units also.

Use a group you never destroy, add units that enter the map/ are bough/revived etc. there. Remove dead units.

The Crow Form adding shouldn't be done in the looping trigger. As far as I can see, this shouldn't be done in the looping trigger as it goes to the then only once:
  • (Load 0 of TempInteger from Pathing) Equal to 0
And like Bribe said, make the two hashtable values normal variables.
I also recommend Unit Indexer instead of a hashtable due to arrays being faster.

Efficiency should be improved.
Bribe, 12th Aug 2011

  • Hashtable - Save 30 as 0 of 0 in Pathing
  • -------- *Gravity Level* Note that if you make it 0 units will be suspended in air. --------
  • Hashtable - Save 8 as 0 of 1 in Pathing
These two should be normal variables, not hashtable values.

Custom script: set udg_TempUnit = GetEnumUnit()
Set TempInteger = (Key (Picked unit))

The custom script is still unnecessary and still you reference (Picked unit) even though you had it set to a variable right above it. Reference the variable - don't call the function again.

Because you reference every single unit in the map every 0.03 seconds, I strongly advise using arrays with GUI Unit Indexer instead of hashtables, because hashtables are way slower than arrays.
 
>.>
._.
-.-
o.o
o_O
o_O
Ok.. Now that I'm over that, time to actually post something serious.

In your Main Trigger, don't use (Picked Unit) after you already did:
  • Custom script: set udg_TempUnit = GetEnumUnit()
Use that variable instead.

Also, instead of adding and removing the crow form ability, do this:
  • Custom script: if UnitAddAbility(udg_TempUnit,'Arav') then
  • Custom script: call UnitRemoveAbility(udg_TempUnit,'Arav')
  • Custom script: endif
This is much safer (A unit that already has the ability would be f***ed if you add and remove the ability.


Btw, this was done along time ago in vJass by Nestharus :p
He called it CliffBound.
Then he wrote SlopeSpeed, but unfortunately, they're sorta graveyarded :p

One last thing, always remember this:
Never repeat stuff like (Picked Unit)...
Set them inside variables and then use said variables instead of calling the function again and again and again :p
 
Orly? Already been done?

Dont worry about that, they were graveyarded :p

Here's a tip, setting the unit's fly height to 0 moves the unit to the ground. If you want to allow units to move underground, the tunnel (Underground tunnel that is) should have it's base as part of the terrain and the cieling should be a doodad ^^
 
Level 12
Joined
Dec 17, 2009
Messages
951
u can fit it into a Grand Chase map like, with some jump (ground to plataforms)?
 
Level 12
Joined
Dec 17, 2009
Messages
951
but non jass spells make units "move" for each second? or it detect units height, without any chance to face a invisible wall lol?

k. ill try
 
Level 4
Joined
Jun 22, 2008
Messages
49
Units always make little stops while running down the ramp at the bottom of the map
Also a soldier which fell down in the edge of two overlaying blocks got stuck (see pic)

Otherwise it seems to be a great system, 5* (To lazy to look at the triggers in the moment)
 

Attachments

  • 2.5D_Bug.png
    2.5D_Bug.png
    1.2 MB · Views: 207
Level 12
Joined
Dec 17, 2009
Messages
951
yeah thanks for the jump spell.
but it do not going to work, wc3 plataforms just cant be walkable Under it :x
for mine map idea
 
Level 23
Joined
Jan 1, 2011
Messages
1,504
~Updated to a moderator's request~

"Because you reference every single unit in the map every 0.03 seconds, I strongly advise using arrays with GUI Unit Indexer instead of hashtables, because hashtables are way slower than arrays. "

First off, I'd like you to prove that hashtables are slower then using arrays with your GUI Unit Indexer.
Second, I laughed when you basically advertised your spell in my system.
And it is absolutely essential that I pick every unit every .03 seconds.
I see nothing wrong with using custom script, as this is my system I will do to it what I see fit.
 
Last edited:

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,456
First off, I'd like you to prove that hashtables are slower then using arrays with your GUI Unit Indexer.

Arrays are 4-6 times faster than hashtables, sometimes even faster.

Second, I laughed when you basically advertised your spell in my system.

If it wasn't mine I would still recommend it because it's a much better solution to what you have here.
And it is absolutely essential that I pick every unit every .03 seconds.

Nothing wrong with that. Only if you do this you need to put a huge, huge emphasis on efficiency to make sure your script can handle even tough performance scenarios.

Keep in mind that you might have a way way faster computer than a lot of other people.
So what runs no problem for you may totally lag other computers.
 
Level 23
Joined
Jan 1, 2011
Messages
1,504
Arrays are 4-6 times faster than hashtables, sometimes even faster.



If it wasn't mine I would still recommend it because it's a much better solution to what you have here.


Nothing wrong with that. Only if you do this you need to put a huge, huge emphasis on efficiency to make sure your script can handle even tough performance scenarios.

Keep in mind that you might have a way way faster computer than a lot of other people.
So what runs no problem for you may totally lag other computers.
No one will use this anyway lol
this is was more of a test to see if something like this was even possible. Anyway I don't feel like updating this anymore.
 
Level 5
Joined
Jul 7, 2010
Messages
69
yes...
+please fix the part when a unit tries to get into higher ground..(it makes them blink, stop, and return them to their previous position)...
+can you make a pathing that could stack one another? example. when you're at the ground (i.e base level) you try to walk to high ground (higher pathing) you'll end up walking underneath the pathing, but if you're at higher ground or at least your height (pathing) is higher than where you want to go it allows you to get to that height (pathing). "maybe you can add fly to those units which enters that path? and remove them if the go to base ground or decrease and increase their height depending on the pathing"... also gravity is cool!
 
Top