Calculating if enemies are in "front" of a player

I need to write the application code for my attack spells on my game. One of the attacks that the character class I'm working on now has is called "Shockwave" and is similar to the Shockwave of Warcraft 3. I am able to iterate through a list of all characters to see if they should be damaged or not.



What I want to do is damage the players if they are

-Within 50 units of the player

-Within 15 degrees of the direction the player is facing



So basically it'll be a "cone" of damage that gets done to people in front of the character. I know that I can get a directional vector that points from the character firing the spell to an enemy character by using


Vector3f attackAngle = char.getLocalTranslation().subtract(enemy.getLocalTranslation()).normalize()



And that I could compare that directional vector to the direction the attacking character is looking using

float angle = myDirection.angleBetween(attackAngle);



The only problem is that I can't figure out how to get a directional vector for the direction a spatial is facing. I basically need to do the same thing that cam.getDirection() does, except on a spatial. Let me know if you have any suggestions.

Thanks,
Tyler

To get the direction of a spatial try:

aSpatial.getWorldRotation().getRotationColumn(2);



That's interesting. I tried that same thing using rotation column 1, and clearly it didn't work. I had assumed it would go X,Y,Z and 0,1,2 respectively. It doesn't make sense to me that rotation around the Z-Axis would return that. Could you explain it to me?



By the way, it worked. Thank you very much. Now I can put the finishing touches on these spells.

I think it does go the way you put it, if you think of it as giving you back the axis itself.

So the y axis would be pointing up through your head while the z axis points forward.

Ooh. So basically, if you imagined the three arrows shooting out of the origin, it gives you the vector of the Z-arrow itself?

Right, that's the way I visualize it.

Awesome. Thanks a ton!