Question by
Anima_97 · Aug 16, 2017 at 09:36 PM ·
unity 5raycastunity5raycasthit2d
Raycast2d detects hit when theres not
I did a function that tells if the player is grounded or not, in order to avoid jumping mid air. But when testing it, the player is able to jump endlessly, unless it's already going down.
private bool isGrounded(){
RaycastHit2D playerToGround = Physics2D.Raycast(transform.position + (new Vector3(0, -0.5f)), Vector2.down, 0.2f);
return playerToGround == true;
}
I cant figure out what's wrong, i have used a couple of ways of using raycast, and had the same problem
Comment
Answer by kpetkov · Apr 04, 2018 at 03:40 PM
Disable all the attached colliders to this gameObject, and after the Raycast enable them again.
Your answer
Follow this Question
Related Questions
Tag doesn't work when gameObject is a child of the Main camera? 1 Answer
Master Audio source volume control with slider 1 Answer
crash bug 5.5 0 Answers
The camera only sees the skybox 0 Answers