I’m trying to detect ground, on both platforms and the main ground, in my 2d game. So, What I’ve done is given all of my platforms and my main ground the tag “ground”. However, I can’t seem to get my IsGrounded() method to work. Can someone help me out?..
bool IsGrounded()
{
foreach(GameObject groudnObj in GameObject.FindGameObjectsWithTag("ground")){
if(Vector3.Distance(collider2D.transform.position, groudnObj.collider2D.transform.position) < 2f){
if(groudnObj.collider2D.transform.position.y < this.collider2D.transform.position.y){
return true;
}
}
}
return false;
}
Thank you! Linecast is what i was looking for :) The documentation on the new 2d system isn't very good yet.
– Vis-Studios