Topic was automatically imported from the old Question2Answer platform.
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?
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.