Sorry for my poor English guys 
I have some problem with this method.
I tried to make the object jump. But “isGrounded” randomly sets to “true” when groundCheck is not in position of “Ground”-layer objects.
How can I fix this problem?
There is a code from Update:
var ballPos: Vector2 = new Vector2 (ballContainer.transform.position.x, ballContainer.transform.position.y);
var grCheckPos: Vector2 = new Vector2 (groundCheck.position.x, groundCheck.position.y);
isGrounded = Physics2D.Linecast(ballPos, grCheckPos, 1 << LayerMask.NameToLayer("Ground"));
if (isGrounded)
{
Debug.Log("Grounded");
jumpCheck = true;
}
if (!isGrounded)
{
jumpCheck = false;
}
Pyrian
2
Wow, we so often see questions about collisions not occurring, it’s almost refreshing to see a question about mystery collisions instead. It’s also much easier to find out what’s happening.
You could try something like:
RaycastHit2D GroundCheck = Physics2D.Linecast(ballPos, grCheckPos, 1 << LayerMask.NameToLayer("Ground"));
if (GroundCheck) Debug.Log("Ground hit " + GroundCheck.collider.name + " at " +
GroundCheck.point.ToString() + "(" + ballPos.ToString() + " - " +
grCheckPos.ToString() + ")");
Then you’ll be able to see exactly what and where the Linecast is “randomly” intercepting something.