Post
by Mimatas » Fri Jul 09, 2004 12:21 pm
It can be done using Cos and Sin functions. I believe there's a way to get your heading in degrees... (not sure where it starts, but that can be figured out). From that point, it's just a matter of doing the equation:
cos(angle) = x/15, sin(angle)=y/15 (or x=15cos(angle), y=15sin(angle)) to get the x/y coordinates. The z coordinate, on the other hand, may be tricky. Since we don't have a way to access map data, we have no way to know what level the ground will be 15 units ahead of us. We can't assume that the ground will be the same height as us, or we wouldn't be able to run up a hill (our point would be below the world, and thus out of LOS). I suppose that if we found the maximum height that a character can run up, we could assume that Z is our height + that number, but it may still cause problems when running up steep cliffs. On the other hand, making the Z too high will cause us to ignore small objects that obstruct our path.
There's the math for you :) You'll have to do some playing around to figure out 1. where our direction angle is referenced from, and 2. which direction (NS or EW) is referenced by x and which by Y... but hopefully this is enough to get you started. Good luck.