Moving 2D object along Z axis

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

I will precise my question, I have a 2dsprite moving in a 2D world (X,Y), and I want to fake a movement on the Z axis. So I believe the best is to play with its dimensions(width,height). But what would be the equation to determine the new dimensions for an object of size(w,h) and moving from 1 meter (consider each 10 pixels is 1 meter for example) forward the camera (Z axis)? What would be the parameters of such a function?

Thanks in advance for your help.

:bust_in_silhouette: Reply From: flurick

The perspective in a 3d image would be based on the cameras focal length (the human eye equivalent is apparently around 23mm).

After doing some reading this would need projecting each object towards the cameras center using some kind of log function and a matrix, but this is slowly building a custom 3d rendering function instead of using a Godot 3d scene which sounds more direct.

If you really want to get into it you are looking for books on “3d rendering” and specifically “perspective scaling factor”.

:bust_in_silhouette: Reply From: siamak-s

First of all thanks for your attention.

Let me describe scenario a bit more, Imagine I’ve a 2d game character in 2dsprite and I want to move that along x,y,z axis. Camera is looking from center without any angle. How we should play with transforms (such as scale, …) that 2d object movement look natural and real (based on real dimensions) in 2d space?

You prefer Godot 3d scene, but how we can use 2d image in 3d scene?

Actually I confused between a huge load of topics for this scenario! I cant find a relation between “Real world scale scene”, “Perspective projection” and of course two new topics “3d rendering” and “Perspective scaling factor”. Would you please tell me more resource about these topics?