Question by
cmanbrandt5 · Mar 12 at 01:51 PM ·
collisioninputboolean
If statement not activating commands
void Update()
{
if (collideWithGround == true)
{
player.transform.Translate(Vector3.back * speedTwo * Time.deltaTime, Space.Self);
}
if (collideWithGround == false)
{
transform.Translate(Vector3.back * Time.deltaTime * speed);
}
if (Input.GetKeyUp(KeyCode.Mouse0))
{
collideWithGround = false;
player.GetComponent<Rigidbody>().useGravity = true;
}
}
private void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.CompareTag("Ground"))
{
collideWithGround = true;
player.GetComponent<Rigidbody>().useGravity = false;
}
}
}
After it collides with the ground and activates the boolean, no matter what type of if command or coroutine or anything I use, I can't get it to deactivate the boolean. I've also tried replacing the if command in the collision method with a while, but that just breaks the entire unity program. Same goes for the useGravity = true command. It's almost as if the entire GetKeyUp if command just doesn't exist.
Comment
Your answer
Follow this Question
Related Questions
Game crashes when function is triggered, 0 Answers
Raycasting not detecting collider 0 Answers
Horizontal input all goes left? 0 Answers
Disable input while falling? 2 Answers
How to fix the problem 0 Answers