What exactly is not working with the code you posted?
To test out if it works just change it to:
void update(){
if(Input.GetKeyDown(KeyCode.Space) || Input.GetMouseButtonDown(0) ) {
Debug.Log("test"); //this
}
But I suspect what you are asking is how to make your "character" go down, which I suppose you have a code made for it already, because "didfly" bool just ain't gonna cut it. Does your going-down code works or not? If your question on how to make your character go down, then you can just have the rigidbody on your character be affected by gravity, and just make him be Kinematic whenever didfly is false:
//add this to the update void with the rest you've got
if(!didfly) { //if didfly is false, then make char Kinematic
rigidbody.isKinematic = true;
} else {
rigidbody.isKinematic = false;
}
That's about it.
↧