2D world... can it be done?

Ultima2876

14-10-2008 06:15:38

Simple question this time; I'm planning on making a 2D game in 3D clothes; the problem is, what happens with the physics? I imagine that if I just make a somewhat flat level, and stick some physics objects in, at some point something is going to move on the z axis, at which point it will likely drop out the world - obviously this is.. well, bad.

Is there a way to stop any movement on the z axis, so that stuff strictly moves on a 2D plane? Alternatively, is there a way of finding out how much something has moved on the z axis, and moving it back before the screen is redrawn?

Thanks in advance :)

micken

14-10-2008 17:31:07

This is definitely possible. I have done this with one of my projects. What I did to achieve this was set a standard height for all of the physical objects, so that nothing should come out of the Z axis. This will however happen and after a lot of searching I found that if you create a CustomTransformCallback and set the Z value of it's position to 0 inside, it will not leave the x/y plane. I think this works because the transform callback is the last call before ending the physics frame. It is a good idea to set the position of your graphical representation of the object in this callback as well.

Ultima2876

14-10-2008 22:04:03

Nice one, I will definitely try this. Thanks :)