why i get that unity (A namespace can only contain types and namespace declarations) error?

  • Thread starter Thread starter cryzvs
  • Start date Start date
C

cryzvs

Guest
private Rigidbody2D myRigidbody ;

// isGrounded

public bool isGrounded ;
public LayerMask groundLayers ;





// Start is called before the first frame update
void Start()
{
myRigidbody = GetComponent<Rigidbody2D>() ;
}

// Update is called once per frame
void Update()
{
myRigidbody.velocity = new Vector2(moveSpeed, myRigidbody.velocity.y);

if (IsGrounded() && (Input.GetKeyDown(KeyCode.Space) || Input.GetMouseButtonDown(0)))
{
myRigidbody.velocity = new Vector2(myRigidbody.velocity.x, jumpForce);
}



}
}
private bool IsGrounded()
{

float extraHeightText = .01f;
RaycastHit2D raycastHit = Physics2D.Raycast(boxCollider2D.bounds.center, Vector2.down, boxCollider.bounds.extents.y + extraHeightText);
ConsoleColor rayColor;
if (raycastHit.Collider != null)
{
rayColor = Color.green;
}
else
{
rayColor = Coler.red;
}
Debug.DrawRay(boxCollider2D.bounds.center, BitVector32.down * (boxCollider.bounds.extents.y + extraHeightText));
return raycastHit.collider != null;

}

if i run this isgrounded function inside of the monobehievor funktion i get an other error

sry for my english andy way of discribing iam new at programming in C#

Continue reading...
 
Back
Top