I need a C # script that does 2 commands with a single EX key: (I want to make my character squat by pressing "c" and when I press again the character to rise again) could anyone help me?
I need a C # script that does 2 commands with a single EX key: (I want to make my character squat by pressing "c" and when I press again the character to rise again) could anyone help me?
Basically you need a flag to check whether it is crouched or not.
private boolean agachado = false;
public void keyPressEvent(object sender, KeyEventArgs e){
if(e.KeyCode == Keys.C){
if(agachado){
levantar();
}else{
agachar();
}
}
}
public void agachar(){
this.agachado = true;
//resto do codigo pra agachar
}
public void levantar(){
this.agachado = false;
//codigo pra levantar
}