Need help coding an attack!

jwoo13jwoo13 Member Posts: 8
edited December 2011 in Working with GS (Mac)
Hey guys, I've come across my next problem in creating a simple platformer game- coding a simple melee attack.

As of now, when my player presses space (his attack button) he does a simple slash with a sword forward.
I have a global variable called "attacking" that becomes true when this happens, and when attacking is true and the player collides with the enemy, the enemy is destroyed. While this works on a basic level, it has a major glitch. If I am facing away from the enemy and use my attack, the enemy will still die, even if he does not touch the sword. This is because the entire player basically becomes invincible, not just the sword. Is there a way to fix this?

Thanks to everyone for helping me thus far, I really appreciate all of your guys' opinions!
Sign In or Register to comment.