Create a variable for each player; attack1 and attack2, global, integers.
On keydown>attack button>player1
- Code: Select all
attack1=1;
Then on player1>animationfinish>attackanimation:(use the 'wait for frame' here:)
- Code: Select all
attack=0;
so on player2>collision>anyside>player1:
- Code: Select all
if (attack1==1){get hurt code here;}
Now it gets just a tiny bit more complicated. You only want to be hurt by the attacking side of player1, not his backside.
To determine sides of player is easy; make a variable called face, actor integer.
When player1>keydown>right:
face=1;
and on player1>keydown>left
face=0;
So now you can combine them, which actually means splitting the event into two;
one is collision>leftside>player1:
- Code: Select all
if (attack1==1 && player1.face==0){ get hurt}
And collsion>rightside>player1:
- Code: Select all
if (attack1==1 && player1.face==1){gethurt}
Two things i'd like to point out here:
1: i described this all as though i were player2
2: i used two different variable methods. One is actor integer, in which i said "player1.face", and the other was global integer, in which i said "attack1".
You can use either method, which ever works for you.
Global integers: Cons: require new integer, or array cell, for each actor who uses them. Pros: Can be saved. Simple To call.
Actor Integers: Cons: cannot be saved without rerouting them to a global integer. Must state actor name before stating variable, when called from another actor. Pros: can be used for any number of actors.
Hope this helps. If you have any questions, just ask!