Hi, I'm trying to create a script for a fighting system like Street Fighter, 1v1 but with Z-axis movement working. So, when holding "moveleft," the player move left and it doesn't turn around or turn player back to the enemy. The character always faces where the opponent is. This way, when holding back, the player uses the backwalk and stays facing the opponent. It worked, but the Z buttons don't function in this backwalk.
The moveup and movedown buttons are simply ignored in the backwalk animations.
I tried replacing the backwalk with a Follow22, but the result is the same. What is wrong with my script?
The moveup and movedown buttons are simply ignored in the backwalk animations.
I tried replacing the backwalk with a Follow22, but the result is the same. What is wrong with my script?
Code:
anim idle
loop 1
delay 20
bbox 86 17 68 541
offset 106 545
frame data/chars/template/1_0-0.png
@script
void self = getlocalvar("self");
int plyr = getentityproperty(self,"playerindex");
void target = findtarget(self);
if(!target) return;
float x = getentityproperty(self,"x");
float Tx = getentityproperty(target,"x");
int dir = (Tx < x) ? 0 : 1;
changeentityproperty(self,"direction",dir);
// BACK
if( (dir==1 && playerkeys(plyr,0,"moveleft")) ||
(dir==0 && playerkeys(plyr,0,"moveright")) )
{
performattack(self, openborconstant("ANI_backwalk"));
}
// FORWARD
else if( (dir==1 && playerkeys(plyr,0,"moveright")) ||
(dir==0 && playerkeys(plyr,0,"moveleft")) )
{
performattack(self, openborconstant("ANI_WALK"));
}
@end_script
frame data/chars/template/1_0-0a.png
anim backwalk
loop 1
delay 8
bbox 9 16 68 270
offset 71 554
frame data/chars/template/1_0-11.png
@script
void self = getlocalvar("self");
int plyr = getentityproperty(self,"playerindex");
void target = findtarget(self);
float speed = 2;
if(!target) return;
float x = getentityproperty(self,"x");
float Tx = getentityproperty(target,"x");
int dir = (Tx < x) ? 0 : 1;
changeentityproperty(self,"direction",dir);
if( (dir==1 && playerkeys(plyr,0,"moveleft")) ||
(dir==0 && playerkeys(plyr,0,"moveright")) )
{
changeentityproperty(self,"velocity",
dir==1 ? -speed : speed, 0, 0);
}
else
{
changeentityproperty(self,"velocity",0,0,0);
setidle(self, openborconstant("ANI_IDLE"));
}
@end_script
offset 70 554
frame data/chars/template/1_0-12.png
Last edited: