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

How to prevent a unit from going over map boundaries?

Status
Not open for further replies.
Level 6
Joined
Feb 16, 2014
Messages
193
So I'm making this unit move using SetUnitX/Y but whenever the unit goes out of the map boundaries(the black area) then the game suddenly crashes, so how can I *detect* if the unit is going out of map boundaries and teleport the unit away from it ?
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,180
Be aware that flying units directly at the border of the map have been known to crash even though they are still in map bounds. As such you really need a few tiles boundary around your map on top of the x/y inside map bounds.
In JASS for example you save max/min values of x/y of map bounds,
and then make comparisons if your x/y are in between.
Or why not test if they are inside the playable map area rect? Should work with most maps.
 
Level 6
Joined
Feb 16, 2014
Messages
193
Sorry for the late reply xD,
I think I'll try to do it with GUI first, but if I can't then I'll try and use that vJass code PurgeandFire posted :thumbs_up: Thx guys :)
 
Status
Not open for further replies.
Top