z7x9r0
1
I’m using keyboard inputs for character movement in Javascript at the moment.
EXAMPLE:
if(Input.GetKeyDown(KeyCode.D) || Input.GetKeyDown(KeyCode.RightArrow)){move right}
In my swipe script, I have static boolean variables set to false at start and turn true when swipes are detected. Only issue is that they stay true. I need the swipes to act as a key stoke and only be true for one frame.
Any suggestions or ideas? Thank you
EXAMPLE OF WHAT I HAVE TRIED:
PLAYER.js
#pragma strict
static var rightSwipe : boolean = false;
function Update(){
if(Input.GetKeyDown(KeyCode.D) || Input.GetKeyDown(KeyCode.RightArrow) || rightSwipe == true){
//move right
}
SWIPESCRIPT.js
#pragma strict
function Update () { if(swipe was right){ PLAYER.rightSwipe = true;
}
}
z7x9r0
2