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

[Galaxy] Finding Terrain Direction/Angle

Status
Not open for further replies.
Level 2
Joined
Apr 23, 2011
Messages
16
I have a unit colliding with terrain and need help finding the direction the terrain hit was facing.
My unit is a flying unit that ignores terrain height, and collision is detected by the Z of the unit being lower than the Z of the world height.
Terrain can be facing 8 possible ways, the standard 4, and the 4 diagonals.
I attempted to find it through checking point(x+1,y) and point(x-1, y) (then vise versa for the y's), to find which side of the terrain had a higher Z point, but it doesn't have 100% accuracy. I don't need the exact angle of the wall, just if it is closer to 0, 45, 90, etc.
Anyone know a solution? thanks for any help!
 
Level 2
Joined
Apr 23, 2011
Messages
16
How would I find the height of the nearest 3 nodes? and thanks, triangles explains why I'm getting the numbers I'm getting.
 
Level 2
Joined
Apr 23, 2011
Messages
16
i'm not really getting how to find these nodes lol.
I have collision point c, which is somewhere on the side of a terrain cliff. I don't get what diagonal you're talking about either. sorry, i've never heard of any of this before...
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,286
Each square in SC2 is 1*1 unit with diagonals running from origan (lower left) to maximum (upper right).

Thus the 3 nodes which form the triangle are found via.
1. Rounding both X and Y fixed value down to whole unit.
2. Rounding both X and Y fixed values up to nearest unit.
3. Checking if the gradient from node 1 to position is greater than 1 meaning upper left or less than 1 meaning lower right.

This will give you a triangle (3 points of X,Y,Z) from which you can compute the normal to it.
 
Status
Not open for further replies.
Top