Quantcast
Channel: Unity Forum
Viewing all articles
Browse latest Browse all 1466670

Detecting the ground with raycasting

$
0
0
Hi, I'm currently working on a platformer and I wanted to detect the ground using raycasts for jumping

This is the code I wrote in order to do that.

Code (CSharp):
  1.     private float distToGround;
  2.  
  3.     void Start()
  4.     {
  5.         distToGround = collider.bounds.extents.y;
  6.     }
  7.  
  8.     bool isGrounded ()
  9.     {
  10.         return Physics.Raycast(transform.position, -Vector3.up, distToGround + 0.1);
  11.     }
  12.  


I thought that this would work but I get these errors.


error CS1502: The best overloaded...

Detecting the ground with raycasting

Viewing all articles
Browse latest Browse all 1466670

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>