Why does 2D vector use vector3 instead of vector2

Why does the rigidbody2D.addForce example in the docs, use a Vector3 to describe the position of the the object here:

I assumed 2D games would only use 2D objects. I’ve noticed a few code snippets online for move and jump scripts that used Vector3s in them. If I am creating a 2D platform game, where my directions are only up,down,left,right, is it correct to use a Vector2 or should I use Vector3?

They’re interchangeable. In Unity, there’s functionality no difference between a 2D game and a 3D game - it’s just a different camera perspective.

For the most part, you’re fine with just using the x and y axes, but there can be some cases where z-axis depth is useful.
For instance, animation. If you want to make any sort of semi-realistic walking animation in a top-down 2D game, you can still animate the moving parts like you would in 3D animation, and it would still look good in the top-down camera perspective.

1 Like

True depth, true action.

If you’re going to necro a thread, please in the very least, add some value to it.

Let’s close this thread.

1 Like