How to alternate character with one touch?
So I want a script in which if the player touches the screen one time, the character goes up. If he/she touches the screen again, it goes down. This alternates per tap on the screen.
Sorry in advance if this is a stupid question. I'm new to the programming world.
Answer by Veerababu.g · Dec 19, 2015 at 05:45 AM
void Update(){
if (Input.GetMouseButtonDown (0)) {
isHit=!isHit;
if(isHit==true){
//add upForce
}else
//add down force
}
forgot to mention isHit is a bool variable.make sure when u adding down force the up force will be 0.as well for up force down force is 0
Your answer
Follow this Question
Related Questions
Simple Host - Client Callback 0 Answers
Separate Input from Touch on GUI 0 Answers
How to replace KeyCode.Space with a simple tap on Android? 1 Answer
Save Stations like in Dead Space and Resident Evil VII 0 Answers
How do I make somthing happen when the Player reaches a certain x, y, z position? 0 Answers