diff --git a/Assets/Scripts/PlayerController.cs b/Assets/Scripts/PlayerController.cs index 2984b4c2b..b582f57b3 100644 --- a/Assets/Scripts/PlayerController.cs +++ b/Assets/Scripts/PlayerController.cs @@ -388,7 +388,7 @@ bool isOccupied(Vector3 pos) foreach (Vector3 checkDir in checkDirs) { Vector2 dir2 = new Vector2(checkDir.x, checkDir.y); - float length = 0.01f;// 1.7f; + float length = 0.4f;// 1.7f; dir2 = dir2.normalized * length; Vector2 start = (pos2 + dir2); //Debug.DrawLine(pos2, start, Color.black, 1); @@ -398,7 +398,19 @@ bool isOccupied(Vector3 pos) GameObject ground = rch2d.collider.gameObject; if (ground != null && !ground.Equals(transform.gameObject)) { - return true;//yep, it's occupied + //test opposite direction + start = (pos2 + -1*dir2); + rch2d = Physics2D.Raycast(start, dir2, length); + Debug.DrawLine(start, start+dir2, Color.black, 1); + if (rch2d && rch2d.collider != null) + { + ground = rch2d.collider.gameObject; + if (ground != null && !ground.Equals(transform.gameObject)) + { + return true;//yep, it's occupied on both sides + } + //nope, it's occupied on one side but not the other + } } } }