UNITY 2D: Need help to stop player input for few seconds.
Hi. I made a scripts that enables the player to WallJump, but, being the movement functions called once per frame, if i keep the movement button held my character just does micro-jumps on the wall. I want him to wait for a fixed amount of time before receiving movement inputs again, what do i do?
void FixedUpdate()
{
try
{
this.moveCharacter();
}
catch (UnityException error) { Debug.LogError(error.ToString()); }
}
void moveCharacter()
{
if (Input.GetAxis("Horizontal") != 0)
{
float move = Input.GetAxisRaw("Horizontal");
anim.SetFloat("Speed", Mathf.Abs(move));
rb.velocity = new Vector2(move*maxSpeed, rb.velocity.y);
if ((move > 0.0f && isFacingRight == false) || (move < 0.0f && isFacingRight == true))
{
flip();
}
}
if (Input.GetButtonDown("Jump"))
{
if (IsGrounded())
GetComponent<Jump>().jump();
if (IsGrounded() == false && GetComponent<Jump>().doubleJump)
{
GetComponent<Jump>().doubleJump = false;
GetComponent<Jump>().jump();
}
if (isWalled() && !IsGrounded())
{
GetComponent<Jump>().wallJump();
}
}
}
Comment
Your answer
Follow this Question
Related Questions
How to make fast a coroutine 1 Answer
Compiler error 0 Answers
Jittery background when implementing parallax effect 1 Answer
Problem getting components in loaded scene 0 Answers
Instantiating A group of platform and moving them down 0 Answers