HI
Need some help with a Grounded booleon i am using.
The code basically checks with a raycast if the player is on the floor.
The code works on the initial run and sets isgrounded to true. However when i jump the bool isnt being activated again. Anyone got any help how i make the isgrounded bool run again to check if the player is on teh floor.?
Here is the code. :
public bool isGrounded {
get {
Vector3 position = transform.position;
Debug.Log ("YO");
position.y = GetComponent<Collider2D>().bounds.min.y + 0.1f;
float length = isGroundedRayLength + 0.1f;
Debug.DrawRay (position, Vector2.down * length);
bool grounded = Physics2D.Raycast (position, Vector3.down, length);
return grounded;
}
}
THis is set to TRUE when i start the game.
i then use the following line to prevent double jumping
if (Input.GetKeyDown (KeyCode.Space) && isGrounded == true) {
just need help on how to make the code check the public bool again.
Any help would be appreciated.
Thanks