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

Finding Terrain Angle/Direction Facing

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 terrain 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 19
Joined
Feb 4, 2009
Messages
1,313
wc3 uses a grid of 32x32 for z so make sure you get the closest of these points to yours

I am facing a similar problem right now and I found out that dealing with collisions by using vectors is much faster than using slow sin and cos calls (I am doing that in c an d wc3 math is slow anyway so it might not matter much for you) but it definitely is an interesting way to deal with it
 
Level 2
Joined
Apr 23, 2011
Messages
16
get the angle between points (the previous and the current)... but you would need a timed loop which saves the previous point to make this accurate and return the values...

I actually happen to have something similar to a timed loop, but this wouldn't work because of the 2 possible angles it could deflect at. And that's why I need the normal angle of the terrain.:(
 
Level 2
Joined
Apr 23, 2011
Messages
16
Yeah, I thought that the Galaxy and JASS solutions would be similar, and I didn't know how much support Galaxy had yet.
but now I don't think that they'd be that similar after all. Unless warcraft 3 has triangles too...
 
Level 2
Joined
Apr 23, 2011
Messages
16
Oh alright haha. So how do I find the three nodes? Would I take the x and y and find the corresponding triangle?
 
Level 2
Joined
Apr 23, 2011
Messages
16
Dr_Super_Good solved my problem, thanks to him, but just to follow up...
It would have two possible angles (at least) because if something is traveling let's say south east, then it could hit a wall facing north, or a wall facing west. If it hits the wall facing north it will bounce to the north east, if it hits the wall facing west, it will bounce to the south west.
 
Status
Not open for further replies.
Top