Jump Actuation
I'm trying to implement a system where my code is able to detect when the player has touched the floor after jumping and now does not jump. The way I have it right now is that the player can only jump when hes on ground (I want to keep this way). Basically if the player hits the ground and doesn't time his jump key stroke properly with when the character hits the ground and isn't able to jump I want some other code to run. However if the player hits the ground and does time his jump key stroke properly and jumps as soon as hits the ground some other code should run. I want a system to be able to detect whether he has hit the ground and not jumped AND whether he has hit the ground and has jumped at the same instant. My if statements aren't working because Im using grounded as a condition which obviously is going to be true whether or not he times the jump properly.
Any help is appreciated.
Answer by blakewmcleod · Mar 12 at 03:18 AM
what im gettiing is that you want the player to jump right as he hits the ground and not to late after he hits the ground.
Maybe when you use an IF statement you could set a coroutine(coding timer) to end in a short period of time and when the coroutine ends the character.ProperStrokeTime would equal false but if he jumps during that time the character.ProperStrokeTime would be true
if the character is not touching the ground the character.ProperStrokeTime would be true by default
so
if(character.IsGrounded == true)
startcoroutine("blahblahblah");
// IEnumerator is a corotine, it does whatever than waits when you do a yield return
IEnumerator blahblahblah(){
yield return new WaitForSeconds(0.4f){
character.ProperStrokeTime = false;
}
void otherFunc(){
if(character.IsGrounded == false)
character.ProperStrokeTime = true;
}
Your answer

Follow this Question
Related Questions
Checking if the player jumps while not grounded 0 Answers
Why won't my character jump smoothly? 0 Answers
After jump animation problem 0 Answers
make rigidbody jump and maintain velocity 1 Answer
how to jump in a 2D game 2 Answers