Having problem with creating a collider

If you’re following a tutorial, can you not just follow it in more detail? Are you sure it’s exactly the same?

Don’t use captures of code, please use code-tags and also show the full errors you get which include the line/column numbers.

Here’s the API docs for BoxCast so you can see what argments it’s expecting: Unity - Scripting API: Physics2D.BoxCast

Notice how the compiler is saying I cannot find the method with these argument types? It’s trying to find a method which takes an “int” as the 3rd argument and there isn’t one. You’re passing “0” which isn’t float (look at the link above).

One thing you should try to do is use the correct format for floating point values. Floating point values in C# are 12.42f or 0f for instance. In your code, the things you are passing are the wrong types so you’re passing in Vector3 where it’s expecting Vector2 and whilst that is being converted, if you do too much of this stuff, passing in things like “0” for floating point, it can cause the compiler to not understand which method you want. By default “0” is assumed to be double precision but it then has to figure out if you mean “int” or “float”. Use the float format as I mentioned here.

2 Likes