What's the difference between 2D and 3D character movement?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By flamingcow148

Hello, I’m about to start work translating my gdscript 2D platformer character code to 3D and I was hoping to get some advice on any major differences. Some questions I have are:

Are the built in functions used differently for kinematic movement in 3D vs 2D?
Are there any major mathematical differences?
Is integrating the local forward vector into movement difficult?

Any and all advice would be helpful.

:bust_in_silhouette: Reply From: kidscancode

You’ll find that the kinematic functions are the same: move_and_slide(), etc., and work in much the same way. You’ll be using Vector3 instead of Vector2.

However, being in 3 dimensions does introduce an additional level of mathematical complexity, especially when it comes to rotations. In 2D, there is only one axis of rotation, while in 3D there are infinitely many.

Your object’s position/rotation/scale are stored in a Transform, which contains an origin (location) and a basis (rotation/scale). You’ll use the transform.basis to get the object’s local axis vectors. For example, the forward vector of a 3D object is -transform.basis.z.

There’s a good overview doc here: Using 3D transforms — Godot Engine (stable) documentation in English

Thanks for the prompt answer. The info you gave is really good and the article is super complete. I’ll study that article in more detail soon.

flamingcow148 | 2021-07-24 20:20