3-D movement/perspective

I’ve got a character that I want to move around in kind of a 3-D environment. When he walks up or down he gets smaller or larger as he moves into the distance or gets closer to the screen. The problem is that as he walks away it looks like he starts running really fast.

I have it set up so that when you hit the up or down key, a y_movement_speed variable gets set to 5 or -5 (depending on if the character is going up or down). Then the character’s movie clip just adds this amount to its _y value on every frame. I have another variable increase or decrease the yscale of the movie in the same way.

The obvious problem is that as the character moves away and gets smaller, the y_movement_speed variable stays the same so the movie clip is always moving at 5 pixels per frame. A tiny movie clip moving at 5 pixels looks like its going a lot faster than a big movie clip moving at 5.

I need a good way to decrease the y_movement_speed variable as movie clip gets smaller.

Well, I found one solution. I made the y_movement_speed a fraction of the hight of the movie clip. So as the movie clip gets smaller, the y_movement_speed variable gets smaller too.

the horizontal and vertical position of an object in 3d space, when projected onto a 2d screen has a direct relationship to it’s distance from the camera (it’s ‘Z’ position).
the formula is as follows:
_Xposition = _XscreenCenter+(_FieldOfView*(_Xposition/_Zposition))

this is the generic formula for 2d projection of objects in 3d space.
if you use that formula for placing your character on the screen, the speed variable doesn’t need to change.
you could also try placing affecting the movement like this:
_Move = _FieldOfView*(_Speed/_Zposition)

or, if you don’t want an extra variable, you could do this:
_Move = _Speed/_Zposition

that way when the object is farther from the camera the speed is slower in direct proportion to it’s distance from the camera.
example:
when the object’s _Zposition is 20 units from the camera, and it’s speed is 10 units…
_Move = 10/20
so it’s speed on the screen would be 0.5 units at that distance.
when the object’s _Zposition is 40 units from the camera, and it’s speed is 10 units…
_Move = 10/40
the speed onscreen would then be 0.25 units.

hope that helps,
jeremy