O Ilusionista
Captain 100K
Hi guys. I want to limit how far a character (and only that one, which is a weapon from another character) can walk in Z axis.
He would either no move in z axis at all or just move few pixels.
What would be the best solution for that? The right area to put a script for that would be "onmovezscript", right?
I can think in how I make it stop to move by checking the his Z position on the stage and setting his Z velocity to 0, but how to make it able to move again?
Or it would be better to adapt the "keymove" scripted function to take care of the z position?
He would either no move in z axis at all or just move few pixels.
What would be the best solution for that? The right area to put a script for that would be "onmovezscript", right?
I can think in how I make it stop to move by checking the his Z position on the stage and setting his Z velocity to 0, but how to make it able to move again?
Or it would be better to adapt the "keymove" scripted function to take care of the z position?
Code:
void keymove(float V)
{// Move hero if direction button is pressed
void self = getlocalvar("self");
int iPIndex = getentityproperty(self,"playerindex"); //Get player index
float xdir = 0;
float zdir = 0;
if (playerkeys(iPIndex, 0, "moveleft")){// Left is pressed?
xdir = -V;
} else if(playerkeys(iPIndex, 0, "moveright")){// Right is pressed?
xdir = V;
}
if(playerkeys(iPIndex, 0, "moveup")){// Up is pressed?
zdir = -V/2;
} else if(playerkeys(iPIndex, 0, "movedown")){// Down is pressed?
zdir = V/2;
}
changeentityproperty(self, "velocity", xdir, zdir);
}