- Home /
Question by
gimoj · May 13, 2014 at 09:26 PM ·
groundlinecastgroundedground detection
How to set up line cast for two groundchecks?
I have two levels, high ground and low ground. I'm try to do linecast ground checks for both of these levels but I think I got the syntax wrong. I got this from a youtube vid and it works just fine for the low ground but I'm having trouble getting it to work for the High ground.
High Ground:
void GroundCheck()
{
Debug.DrawLine (sightStart.position, sightEnd.position, Color.blue);
grounded = Physics2D.Linecast (sightStart.position, sightEnd.position, 1 << LayerMask.NameToLayer("HighGround"));
}
Low Ground:
void GroundCheck()
{
Debug.DrawLine (sightStart.position, sightEnd.position, Color.red);
grounded = Physics2D.Linecast (sightStart.position, sightEnd.position, 1 << LayerMask.NameToLayer("LowGround"));
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613144950im_/https://answers.unity.com/themes/thub/images/avi.jpg)