Boxcast with circle? o.O

Hi folks. Nice to be here. I am totally new to this terrain. I understand some programming logic, but not really C#.

I am Playing around with some basic code on a basic map to develop skills. In Unity2D I want to make the Player a Ball. The Problem is the Hitbox and so… It cannot be based on texture layers, since I am using a NON FLAT surface. Circlecast does not exist as I am aware, so Boxcast is one way to archive something. I might use multiple raycasts soon, when I find out how. First of all, I basically copied some code from youtube. It has the debug feature, to show me some lines. I would guess, that the 3 lines would mark left, right and bottom edge of the detection. I think, the problem comes from using a circular player and using circleCollider2d - before there was a boxCollider2d in the code.

You can also see in the debug line, that I multiplied the direction Vector by 1000 and 100.

This comes down to the fact, that the numbers are tits-small! I will show you, what they look like in the test:

O1: ((-5,7, -2,4, 0,0), (0,0, 59,1), RGBA(0,000, 1,000, 0,000, 1,000))
O2: ((-7,7, -2,4, 0,0), (0,0, 59,1), RGBA(0,000, 1,000, 0,000, 1,000))
O3: ((-7,7, -2,4, 0,0), (200,8, 0,0), RGBA(0,000, 1,000, 0,000, 1,000))

Okay, I know, they are just used as a direction, but my brain grasps it better, if numbers are bigger than 0,999…
The documentation says, it needs a direction and length. So is on O3 {200,8,0} the direction and the 0 is the length, for example?

    private bool IsGrounded() {
        //return transform.Find("GroundCheck").GetComponent<GroundCheck>().isGrounded;

        float extraHeightText = -1.01f;
        RaycastHit2D raycastHit = Physics2D.BoxCast(circleCollider2d.bounds.center, circleCollider2d.bounds.size, 0f, Vector2.down, extraHeightText, groundLayer);

        Color rayColor;
        if (raycastHit.collider != null) {
            rayColor = Color.green;
        } else {
            rayColor = Color.red;
        }
        Debug.DrawRay(circleCollider2d.bounds.center + new Vector3(circleCollider2d.bounds.extents.x, 0), Vector2.down * (circleCollider2d.bounds.extents.y + extraHeightText), rayColor, 1/60, false);
        Debug.DrawRay(circleCollider2d.bounds.center - new Vector3(circleCollider2d.bounds.extents.x, 0), Vector2.down * (circleCollider2d.bounds.extents.y + extraHeightText), rayColor, 1/60, false);
        Debug.DrawRay(circleCollider2d.bounds.center - new Vector3(circleCollider2d.bounds.extents.x, circleCollider2d.bounds.extents.y + extraHeightText), Vector2.right * (circleCollider2d.bounds.extents.x * 2f), rayColor, 1/60, false);
       
        Debug.Log("O1: " + (circleCollider2d.bounds.center + new Vector3(circleCollider2d.bounds.extents.x, 0), Vector2.down * (circleCollider2d.bounds.extents.y + extraHeightText)*10000, rayColor));
        Debug.Log("O2: " + (circleCollider2d.bounds.center - new Vector3(circleCollider2d.bounds.extents.x, 0), Vector2.down * (circleCollider2d.bounds.extents.y + extraHeightText)*10000, rayColor));
        Debug.Log("O3: " + (circleCollider2d.bounds.center - new Vector3(circleCollider2d.bounds.extents.x, circleCollider2d.bounds.extents.y + extraHeightText), Vector2.right *100* (circleCollider2d.bounds.extents.x * 2f), rayColor));

        //Debug.Log(raycastHit.collider);
        return raycastHit.collider != null;
    }
//based on *Code Monkeys* code for now

Of course, there is also a lot of lack of understanding for now: What does it mean:

circleCollider2d Is this the ball itself or is this realy the circular collider? Because there is no function I understand to get this object. Only:
“private CircleCollider2D circleCollider2d;” and
“circleCollider2d = transform.GetComponent<CircleCollider2D>();”

I am more used to PHP, HTML and CoD4 scripting. And all these languages where absolutely self-explainatory. The circleCollider2d is the object, I am using, right? Well, what does the private CircleCollider2D do? For me this just looks like 2 Variables next to each other. Why does C# suck? I could think, that the CircleCollider2D means the type of the object? (???)

now, that we defined circleCollider2d as a Collider object (???), we can give it a “Value”/assign it to transform.GetComponent<CircleCollider2D>();

Here inlies the next problem in my understanding. 1st: Why the transform. and why does it sometimes work without transform.? 2nd: <CircleCollider2D> What does that mean and why is the bracked not surrounding that text?

circleCollider2d.bounds.center // where do these sub-variables come from and how do I know them all? Is there a debug function to show sub-variables of objects that are available? This definitely would help insanely! Soooo… this is the center coordinates of the object absolute to the world?

new Vector3 // new vector??? Wait, are we now initializing a variable “vector” right inside of a code line?

(circleCollider2d.bounds.extents.x, circleCollider2d.bounds.extents.y + extraHeightText), Vector2.right
circleCollider2d.bounds.extents.x * 2f // floats can’t be multiplied by integer, or am I mistaking this?
and what is circleCollider2d.bounds.extents.x?

Remember: It ALL was boxCollider2d… before.

My goal: Understand this heap of crap language to make my own collision system, that works a charm.

So far, it seems to work reasonably well, except, it sucks on slopes, as expected.

If someome manages to bend my head around that new territory, I would be thankful.

Maybe this will go instead of circlecast

That will only work on 3D colliders.