• 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.

detecting ledges

Status
Not open for further replies.
Level 12
Joined
Mar 21, 2008
Messages
375
how would i go about detecting ledges? in this map if you try to go up a slope that's too steep, it just pushes the unit back; and if you try to go down a steep slope, the unit jumps off

sry if this question is really vague/broad but i'm a clueless mongrel

anyway i don't really want a fully-fledged physics system in my map, but i just want to accomplish two things:
- being able to detect ledges (i.e. steep slopes)
- pushing units away if they try to go up a steep slope

how do
 
Level 12
Joined
Mar 24, 2011
Messages
1,082
You could use the system itself as it is pending for trivial reasons.
It has only one breaking feature, which you won't be using for the slopes, the rest looks like trivial matters.

Otherwise, you could dig up the code out from the system and apply it for your needs.
Edit// I had put a function here, but it is a lil bit more required for this to work.
 
Last edited:
Level 12
Joined
Mar 21, 2008
Messages
375
You could use the system itself as it is pending for trivial reasons.
It has only one breaking feature, which you won't be using for the slopes, the rest looks like trivial matters.

Otherwise, you could dig up the code out from the system and apply it for your needs.
Edit// I had put a function here, but it is a lil bit more required for this to work.

yea seems like ledge detection involves a bunch of functions that are intertwined with each other

if i wasn't 90% jass illiterate i could probably just cherrypick the functions that i need but yeah i'm dumb :ugly:

i just sent a message to the guy who made the system so hopefully he'll respond
 

Kazeon

Hosted Project: EC
Level 34
Joined
Oct 12, 2011
Messages
3,449
To detect terrain slope at a location you can use a function from the system:
JASS:
        static method GetTiltness takes real x1, real y1, real x2, real y2 returns real
            return Sin(GetTerrainZ(x1, y1)-GetTerrainZ(x2, y2))/SLOPE_DETECTION_RADIUS
        endmethod
where x1 & y1 is the location you want to detect. x2 & y2 is the location at which direction you want to detect the terrain slope.
JASS:
x2 = x1 + SLOPE_DETECTION_RADIUS*Cos(direction)
y2 = y1 + SLOPE_DETECTION_RADIUS*Sin(direction)

It returns terrain's slope in radians.
The function will return 0 if the ground is even. Positive result means it's an uphill, and vice versa.

If you want to push unit back if the terrain is too steep, then the code will look something like this:
JASS:
x1 = GetUnitX(main)
y1 = GetUnitY(main)
direction = GetUnitFacing(main)*bj_DEGTORAD
x2 = x1+ SLOPE_DETECTION_RADIUS*Cos(direction)
y2 = y1+ SLOPE_DETECTION_RADIUS*Sin(direction)
if GetTiltness(x1, y1, x2, y2) > MAXIMUM_WALKABLE_TILTNESS then
    // Push unit back
endif
 
Level 12
Joined
Mar 21, 2008
Messages
375
Hey thanks for the reply

it works pretty gud but there's an issue where i can still ascend a steep slope if i just walk through it diagonally (if that makes any sense)

should i be using getLowestPoint instead?
 
Status
Not open for further replies.
Top